PhantomJS

PhantomJS
Original author(s) Ariya Hidayat
Developer(s) Ariya Hidayat
Initial release January 17, 2011
Stable release 2.0.0 / January 23, 2015
Development status Active
Written in C++
Type Headless browser
License BSD
Website phantomjs.org

PhantomJS is a scripted, headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment. PhantomJS is based on Webkit making it a similar browsing environment to Safari and Google Chrome (before Chrome's fork of webkit evolved into Blink). It is open-source software released under the BSD License.

History

PhantomJS was released January 23, 2011 by Ariya Hidayat after several years in development.[1]

The first commit to the public project was in 2011.[2] The project has maintained a steady level of weekly contributions from December 26, 2010 to present.[3] As of February 5, 2015, the project’s open source code repository is watched by 770 people and contributed to by 107 contributors. Also as of February 5, 2015, the project has 1376 open issues and 1252 closed issues.

The logo commonly used to pictorially refer to PhantomJS is a green ghost atop a black background. This refers to the lack of graphical user interface, or main body of the browser, making PhantomJS users seem like ghosts.

PhantomJS usage

The PhantomJS JavaScript API can be used to open web pages, take screenshots, execute user actions, and run injected JavaScript in the page context. For example, the following code will open Wikipedia and, upon loading, will save a screenshot to a file and exit.

console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://en.wikipedia.org/';
page.open(url, function (status) {
  console.log('Page loaded');
  page.render('wikipedia.org.png');
  phantom.exit();
});

Tools using PhantomJS

CasperJS

Shortly after the release of PhantomJS, Nicolas Perriault wrote CasperJS, a suite of libraries on top of PhantomJS that extend its capabilities as a client for automated web page testing. CasperJS and PhantomJS have become valuable enough that similar projects have started to adopt the API as a standard way of interacting with headless browsers.[4][5]

YSlow

Yahoo! developed a version of YSlow that leverages PhantomJS for to gather performance metrics for websites.[6]

Companies using PhantomJS

Other uses for PhantomJS

PhantomJS was made for programmatic control of web sites and has been used for many purposes from visual differencing of websites [11] to automated testing of JavaScript frameworks.[12]

Server Rendering of Client Side JavaScript

With the rise of client-side JavaScript and the SEO problems that practice presents, developers turned to PhantomJS as a way to pre-render static HTML for initial requests,.[13][14] Despite the performance impact of such an approach, it remained one of the simplest ways to improve SEO without rewriting a web application, spawning services trying to automate the process.[15]

Malicious use of PhantomJS

Because PhantomJS is runnable without a UI, scriptable via JavaScript, and is relatively adherent to modern browser specifications, it is commonly used as a way to automate attacks against web sites.[16] PhantomJS mimics legitimate user traffic and can complicate attack mitigation technologies. PhantomJS can also be used to automatically verify logins across disparate web sites[17] (Credential Stuffing), compounding the problems that arise after a site is breached and usernames and passwords are leaked.

Books, Classes and Articles on PhantomJS

See also

References

  1. http://ariya.blogspot.com/2011/01/phantomjs-minimalistic-headless-webkit.html
  2. https://github.com/ariya/phantomjs
  3. https://github.com/ariya/phantomjs/graphs/contributors
  4. http://slimerjs.org/faq.html
  5. http://triflejs.org/
  6. http://yslow.org/phantomjs/
  7. https://twitter.com/leolaneseltd/status/197766152745787392
  8. http://www.slideshare.net/phegaro/linkedin-mobile-how-do-we-do-it
  9. http://threatpost.com/netflix-open-source-security-tools-solve-range-of-challenges/107931#sthash.pcyW3Ksf.dpuf
  10. http://ariya.ofilabs.com/2012/01/one-year-of-wandering-headlessly.html
  11. https://github.com/Huddle/PhantomCSS
  12. http://durandaljs.com/documentation/Testing-With-PhantomJS-And-Jasmine.html
  13. http://eshlox.net/2014/05/04/short-story-about-rendering-html-client-side-vs-server-side/
  14. http://blog.42floors.com/sever-side-rendering-single-page-apps-using-phantomjs-node-js/
  15. http://www.brombone.com/
  16. http://www.darkreading.com/attacks-breaches/ddos-attack-used-headless-browsers-in-150-hour-siege/d/d-id/1140696?
  17. https://gist.github.com/dariusk/4072489
  18. https://books.google.com/books?id=hjE767CCeQwC&printsec=frontcover&dq=phantomjs&hl=en&sa=X&ei=ngPcVJuqA83YoATrq4EY&ved=0CEoQ6AEwCA#v=onepage&q=phantomjs&f=false
  19. https://www.packtpub.com/web-development/phantomjs-cookbook
  20. https://www.packtpub.com/web-development/getting-started-phantomjs
  21. http://threatpost.com/netflix-open-source-security-tools-solve-range-of-challenges/107931
  22. http://www.scribd.com/doc/151866935/Stanford-University-Startups-Engineering-course#scribd
  23. http://www.sitepoint.com/headless-webkit-and-phantomjs/
  24. http://www.wseas.org/multimedia/journals/communications/2014/a165704-469.pdf
  25. http://www.ccs.neu.edu/home/amislove/publications/Pinterest-ICWSM.pdf

External links