Created
June 21, 2012 17:54
-
-
Save nym/2967352 to your computer and use it in GitHub Desktop.
Is it loaded? Is it loaded? Yes it might be. Yes it might be.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require('jsdom'); | |
var fs = require('fs'); | |
var request = require("request"); | |
var jsdom = require("jsdom"); | |
jsdom.defaultDocumentFeatures = { | |
FetchExternalResources : ['script', 'img', 'css', 'frame', 'link'], | |
ProcessExternalResources : ['script', 'img', 'css', 'frame', 'link'], | |
MutationEvents : '2.0', | |
QuerySelector : false | |
}; | |
jsdom.env("http://documentcloud.github.com/backbone/examples/todos/index.html", | |
{ | |
features: { | |
FetchExternalResources : ['script', 'img', 'css', 'frame', 'link'], | |
ProcessExternalResources : ['script', 'img', 'css', 'frame', 'link'], | |
MutationEvents : '2.0', | |
QuerySelector : false | |
} | |
}, | |
function(errors, window) { | |
var foo, elementsArray, lastScript, fooRunner, runFoo, f, item, loadHandler; | |
var document = window.document; | |
runFoo = function(f) { | |
var fooRunner = function() { | |
if (f.src) { | |
console.log(f.src); | |
//console.log(f); | |
console.log("---"); | |
console.log(); | |
} | |
}; | |
setTimeout(fooRunner, 3000); | |
}; | |
elementsArray = document.getElementsByTagName('script'); | |
console.log(elementsArray.length); | |
loadHandler = function(){ console.log("Loaded!"); }; | |
for (var i = 0; i<elementsArray.length; i++) { | |
item = elementsArray[i]; | |
if (typeof(item.src) !== 'undefined') { | |
item.addEventListener('load', loadHandler, true); | |
} | |
try { runFoo(item); } | |
catch(e) {} | |
} | |
console.log("I would like to find out if these scripts were loaded:") | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment