Nodejs + phantomjs vs. pure phantomjs - page load time

I fidgeted for new nodejs and phantomjs objects and wrote some code to measure page load time. I found that page load time is different between phantomjs code wrapped in nodejs compared to pure phantomjs code. Below is the code: phantomjs and nodejs for comparison:

Nodejs:

var http = require('http'), phantom = require('phantom'); url = require("url"); http.createServer(function (request, response) { var start = Date.now(); request.on('end', function () { phantom.create(function(ph) { ph.createPage(function(page) { var _get = url.parse(request.url, true).query; page.open(_get[url], function(status) { if (status == 'success') { var time = Date.now() - start; console.log(time); } }); }); }); }); }).listen(80,''); 

Phantomjs:

 var page = require('webpage').create(); var system = require('system'); var address = system.args[1]; var time = 0; var start = Date.now(); page.open(address, function (status) { time = Date.now() - start; console.log(time + ''); }); 

The time is usually 4 times longer when testing a site using phantomjs. Any ideas?

+6
source share
1 answer

PhantomJS does not support data output, it only opens web pages. phantomjs-node connect them as follows: it creates an instance of ExpressJS and passes the data through its socket.io plus the use of two more libraries. And the data goes:

Webpage> Phantom.js> dnode + node-browserify > Express.js> Socket.io> Node.js

I have the same problem when speed and performance are now read about node-webkit , thats native WebKit without crutches supports Node.js modules.

0
source

All Articles