Created
September 28, 2010 16:00
-
-
Save badsyntax/601260 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This is the conclusion to my tests of determining the best way to cache images. | |
// I used apache access logs to determine when an image was actually requested from the web server. | |
// The following code, although not that elegant, works fine in IE6, IE7, IE8, FF3, Safari, Chrome, Opera | |
var _cacheImages = []; | |
function cacheImages(images){ | |
$.each(images, function(index, val){ | |
var image = new Image() | |
image.src = val; | |
_cacheImages.push( image ); | |
}); | |
}; | |
// The following will NOT work in IE6: | |
function cacheImages(images){ | |
$.each(images, function(index, val){ | |
var image = new Image() | |
image.src = val; | |
}); | |
}; | |
// Also the following will NOT work in IE6 (sorry!) | |
function cacheImages(images){ | |
$.each(images, function(index, val){ | |
new Image().src = val; | |
}); | |
}; | |
// It seems you need to save a reference to the image object in order for IE6 to send a request to retrieve it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment