ariya.io About Talks Articles

glory of the snow

3 min read

Dunkle Sternhyazinthe 2008-3-7a

By Hedwig Storch (Own work), CC-BY-SA-3.0, via Wikimedia Commons.

One day in last December was a solstice. That also means, we have another PhantomJS release, this time at its version 1.4, codenamed Glory of the Snow. While it’s hot, check it out from its code repository and look for 1.4 tag and then compile it. Binary packages and executables may be available for download after few days or weeks, so if you don’t want to build from source, please be patient a little bit.

Originally I had a huge plan for this 1.4 release (see issue 226 for details). Unfortunately, since Qt 4.8 had a very long release process, 2 months from the release candidate to the final release, this timing was not in our favor. Still, if you follow the release notes, there are few goodies which I’d like to mention again here.

The first is the new WebServer module. In some use cases, people want to interact with running PhantomJS instance, as opposed to launching it again and again. For the implementation itself, we use the code from Mongoose, an excellent embedded HTTP server library. The addition of this HTTP server module allows such a kind of two-way communication. A shortened example of this module (refer to examples/simpleserver.js for the complete code):

var server, service;
 
server = require('webserver').create();
 
service = server.listen(8080, function (request, response) {
    response.statusCode = 200;
    response.write('<html><body>Hello!</body></html>');
});

Two important notes before you go crazy. First, this is considered experimental. We still don’t have full integration with the rest of Qt and WebKit machinery, check for the issues related to this WebServer module. Second, use it for process communication and not as a production-grade web server.

Another extra goodie in this release is the convenient script to build PhantomJS statically. Some of you just want to use PhantomJS in e.g. a continuous integration server and thus care less about the availability of system-wide Qt libraries (or even when you don’t have the permission to modify the system). The build script, available for Mac OS X and Linux (see the deploy subdirectory) automatically downloads Qt source code, configures Qt suitable for the build, and finally starts the compile. Nothing will clobber your system, everything will be setup locally. On a modern machine, this process (excluding the download) takes about 30 minutes. For the Linux version, if you choose to use Qt 4.8, there are also additional benefits: remote web inspection, X11-less via QPlatformAbstraction (aka Lighthouse), as well as various PDF improvements (borrowed from wkhtmltopdf).

Last but not least, the new features in 1.4 were not possible if KDAB did not assign their highly-skilled engineers to help with the improvements. Kudos to KDAB and we’ll be forever thankful for the contributions!

Now back to work, we have PhantomJS 1.5 to be ready before March 20, 2012.

Related posts:

♡ this article? Explore more articles and follow me Twitter.

Share this on Twitter Facebook