Book Image

PhantomJS Cookbook

By : Rob Friesel
Book Image

PhantomJS Cookbook

By: Rob Friesel

Overview of this book

Table of Contents (15 chapters)
PhantomJS Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Automating performance analysis with YSlow and PhantomJS


This recipe demonstrates how to set up an automated performance analysis task on a continuous integration server (for example, Jenkins CI) using PhantomJS and the YSlow library.

Getting ready

To run this recipe, the phantomjs binary will need to be accessible to the continuous integration server, which may not necessarily share the same permissions or PATH as our user. We will also need a target URL.

We will use the PhantomJS port of the YSlow library to execute the performance analysis on our target web page. The YSlow library must be installed somewhere on the filesystem that is accessible to the continuous integration server. For our example, we have placed the yslow.js script in the tmp directory of the jenkins user's home directory.

Tip

To find the jenkins user's home directory on a POSIX-compatible system, first switch to that user using the following command:

sudo su - jenkins

Then print the home directory to the console using the...