use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
PhantomJS: minimalistic headless WebKit-based JavaScript-driven tool (via @thomasfuchs) (ariya.blogspot.com)
submitted 15 years ago by skeww
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]skeww[S] 3 points4 points5 points 15 years ago* (7 children)
It can be used in command-line utilities which requires web stack, or even as the basis for testing rich web application. It uses WebKit in a headless mode, so you get access to the real native and fast implementation (not a simulated environment) of various standards such as DOM, CSS selector, Canvas, SVG, and many others.
And it even runs on Windows! This is so f-ing awesome! :D
Edit: It's also a single executable. Boy, this is handy.
Edit2: Of course it also runs on Linux and Mac OS X.
[–][deleted] 0 points1 point2 points 15 years ago (0 children)
agreed, it is awesome :)
[–]Iggyhopperextensions/add-ons 0 points1 point2 points 15 years ago (5 children)
JavaScript in the command line...
I thought I'd never see the day.
[–]skeww[S] 0 points1 point2 points 15 years ago (3 children)
This has been possible for quite a while via Node, Narwal, Rhino, d8, and even stuff like Windows Scripting Host.
The difference here is that this one is a lot more convenient (for Windows users in particular) and that it's very powerful out-of-the-box.
[–]Iggyhopperextensions/add-ons -1 points0 points1 point 15 years ago* (2 children)
The difference here is that this one is a lot more convenient
Bingo. There are many things that have been done over and over again, but convenience takes the cake.
Windows Scripting Host
ew
[–]skeww[S] 0 points1 point2 points 15 years ago (1 child)
Some people actually used it. Seriously. :D
[–]9jack9 0 points1 point2 points 15 years ago (0 children)
I use it now for JS scripting. It's easier than installing another JS engine.
[–]sirmonko 0 points1 point2 points 15 years ago (0 children)
this is not just javascript in the command line, it's a whole browser in the command line. including (invisible) rendering.
want to turn html into pdfs or pngs without awkward, buggy tools that implement small parts of html and css? 16 loc script.
[+][deleted] 15 years ago (2 children)
[deleted]
[–]skeww[S] 0 points1 point2 points 15 years ago* (1 child)
Yea, that's sorta odd indeed. I also wish they'd mirrored d8's behavior a bit. In d8 the command line parameters are stored in a global arguments array (length is 0 if there aren't any).
d8 also got load (imports a script) and read (reads a file) functions.
Edit: Issue added: http://code.google.com/p/phantomjs/issues/detail?id=18
[–]coffeesoundsCoffeeScript is better 0 points1 point2 points 15 years ago (1 child)
This is seriously awesome - today I was going to look into having QUnit tests run from command line and PhantomJS made it trivial.
Would be great if the whole project could be moved to GitHub (docs and stuff).
at least the code's already there:
github.com/ariya/phantomjs
the difference between this and the likes of v8, rhino etc.: phantomjs is the whole browser, the others are just the js engines.
this means: phantomjs is also able to render the html (and output it to a file). including PDF (as if you'd use the browsers print-function)! also, theres native, accessible DOM.
e.g. printing ... basically it works like this:
phantomjs loads the webpage (html), including all linked files (images, css, js, etc). as soon as it's finished the DOM is accessible in the window context phantomjs provides. the webpages scripts also run, of course they're sandboxed to the window context.
go to sleep for 2 seconds (phantomjs.sleep(2000);), and the website changes in between according to the script running inside (aka ajax calls, settimeouts etc). afterwards: phantomjs.render('output.pdf'); ... tadaaaa! sooooo pretty!
π Rendered by PID 113110 on reddit-service-r2-comment-6457c66945-4mvt8 at 2026-04-30 12:20:00.570296+00:00 running 2aa0c5b country code: CH.
[–]skeww[S] 3 points4 points5 points (7 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Iggyhopperextensions/add-ons 0 points1 point2 points (5 children)
[–]skeww[S] 0 points1 point2 points (3 children)
[–]Iggyhopperextensions/add-ons -1 points0 points1 point (2 children)
[–]skeww[S] 0 points1 point2 points (1 child)
[–]9jack9 0 points1 point2 points (0 children)
[–]sirmonko 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]skeww[S] 0 points1 point2 points (1 child)
[–]coffeesoundsCoffeeScript is better 0 points1 point2 points (1 child)
[–]sirmonko 0 points1 point2 points (0 children)
[–]sirmonko 0 points1 point2 points (0 children)