Last active
August 29, 2015 13:56
-
-
Save jhrr/8794592 to your computer and use it in GitHub Desktop.
JQuery image preloader that should work correctly with the hashing mechanism from django-compressor.
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
function preLoadImages () { | |
$.get($('link[rel="stylesheet"]')[0].href, function(data){ | |
r = /url\(['|"]?(\S+\.(gif|jpg|jpeg|png)[^'(]*)['|"]?\)/ig; | |
while (match = r.exec(data)){ | |
var cacheImage = document.createElement('img'); | |
cacheImage.src = match[1]; | |
} | |
}); | |
} | |
preLoadImages(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment