Skip to content

Instantly share code, notes, and snippets.

@yuxel
Created December 8, 2013 12:05
Show Gist options
  • Save yuxel/7856535 to your computer and use it in GitHub Desktop.
Save yuxel/7856535 to your computer and use it in GitHub Desktop.
var sd = sd || {};
sd.utils = sd.utils || {};
sd.utils.preloadImage = function (url) {
var deferred = $.Deferred();
var image = new Image();
image.src = url;
image.onload = deferred.resolve;
image.onerror = deferred.reject;
if (image.complete) {
deferred.resolve();
}
return deferred.promise();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment