Skip to content

Instantly share code, notes, and snippets.

@kirbysayshi
Created March 25, 2011 04:07
Show Gist options
  • Save kirbysayshi/886348 to your computer and use it in GitHub Desktop.
Save kirbysayshi/886348 to your computer and use it in GitHub Desktop.
jsdom appears to favor its default parser vs another when they are used in the same script?
var jsdom = require('jsdom@0.2.0')
,fs = require('fs')
,testHtml = fs.readFileSync(__dirname + '/british_throne.html', 'utf8')
,html5 = require('html5')
,window
,document
,start = +new Date()
,end;
start = +new Date();
window = jsdom.jsdom(testHtml, null, {
features: {
FetchExternalResources : false,
ProcessExternalResources: false,
QuerySelector: true,
MutationEvents: false
}
//,parser: html5
}).createWindow();
document = window.document;
end = +new Date();
console.log( (end - start) + ' ms to load' );
start = +new Date();
window = jsdom.jsdom(testHtml, null, {
features: {
FetchExternalResources : false,
ProcessExternalResources: false,
QuerySelector: true,
MutationEvents: false
}
,parser: html5
}).createWindow();
document = window.document;
end = +new Date();
console.log( (end - start) + ' ms to load' );
// each take about 10 seconds on my core i5 !?
var jsdom = require('jsdom@0.2.0')
,fs = require('fs')
,testHtml = fs.readFileSync(__dirname + '/british_throne.html', 'utf8')
,html5 = require('html5')
,window
,document
,start = +new Date()
,end;
start = +new Date();
window = jsdom.jsdom(testHtml, null, {
features: {
FetchExternalResources : false,
ProcessExternalResources: false,
QuerySelector: true,
MutationEvents: false
}
//,parser: html5
}).createWindow();
document = window.document;
end = +new Date();
console.log( (end - start) + ' ms to load' );
// takes about 10 seconds
#!/bin/bash
# I'd put the html into the gist, but it breaks github's servers because it's so large!
curl http://en.wikipedia.org/wiki/Line_of_succession_to_the_British_Throne > british_throne.html
var jsdom = require('jsdom@0.2.0')
,fs = require('fs')
,testHtml = fs.readFileSync(__dirname + '/british_throne.html', 'utf8')
,html5 = require('html5')
,window
,document
,start = +new Date()
,end;
start = +new Date();
window = jsdom.jsdom(testHtml, null, {
features: {
FetchExternalResources : false,
ProcessExternalResources: false,
QuerySelector: true,
MutationEvents: false
}
,parser: html5
}).createWindow();
document = window.document;
end = +new Date();
console.log( (end - start) + ' ms to load' );
// takes approximately 70 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment