Created
September 14, 2009 01:29
-
-
Save eligrey/186419 to your computer and use it in GitHub Desktop.
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
/* | |
* importScripts.js simplified (no IE <8 or data: URI support) | |
* | |
* 2009-10-17 | |
* | |
* By Elijah Grey, http://eligrey.com | |
* | |
* Implements HTML5 web workers' importScripts() function using synchronous XMLHttpRequests. | |
*/ | |
"use strict"; | |
self.importScripts || (self.importScripts = (function (globalEval) { | |
return function importScripts() { | |
var args = Array.prototype.slice.call(arguments), | |
len = args.length, | |
i = 0, | |
xhr = new XMLHttpRequest(); | |
for (; i < len; i++) { | |
xhr.open("GET", args[i], false); | |
xhr.send(null); | |
globalEval(xhr.responseText); | |
} | |
}; | |
}(eval))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment