Skip to content

Instantly share code, notes, and snippets.

@mattheworiordan
Created October 24, 2012 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattheworiordan/3945319 to your computer and use it in GitHub Desktop.
Save mattheworiordan/3945319 to your computer and use it in GitHub Desktop.
PhantomJS working example
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit();
}
t = Date.now();
address = system.args[1];
page.viewportSize = { width: 600, height: 600 };
page.open(address, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
phantom.exit();
} else {
t = Date.now() - t;
window.setTimeout(function () {
console.log('Loading time ' + t + ' msec');
page.render('screenshot.png');
phantom.exit();
}, 200);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment