Skip to content

Instantly share code, notes, and snippets.

@eligrey
Created September 14, 2009 01:29
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 eligrey/186419 to your computer and use it in GitHub Desktop.
Save eligrey/186419 to your computer and use it in GitHub Desktop.
/*
* 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