Created
December 8, 2013 12:05
-
-
Save yuxel/7856535 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
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