Skip to content

Instantly share code, notes, and snippets.

@Williammer
Created June 9, 2014 09:11
Show Gist options
  • Select an option

  • Save Williammer/082de8ebce0615be3eb1 to your computer and use it in GitHub Desktop.

Select an option

Save Williammer/082de8ebce0615be3eb1 to your computer and use it in GitHub Desktop.
jsPerform.preload.js - preload certain element at the right time, such as user login;
var preload;
if ( /*@cc_on!@*/ false) { // IE sniffing with conditional comments
preload = function (file) {
new Image().src = file;
};
} else {
preload = function (file) {
var obj = document.createElement('object'),
body = document.body;
obj.width = 0;// make the file invisible
obj.height = 0;
obj.data = file;
body.appendChild(obj);
};
}
preload('my_web_worker.js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment