Created
June 6, 2012 09:42
-
-
Save stenvdb/2880975 to your computer and use it in GitHub Desktop.
JQuery: Check if image is in browser cache
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
alert("Expected: true or false\n" + | |
cached(big_img) | |
+ "\n\nExpected: false (cache-busting enabled)\n" + | |
cached(big_img + "?" + new Date().getTime())); | |
function cached(url){ | |
var test = document.createElement("img"); | |
test.src = url; | |
return test.complete || test.width+test.height > 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment