Skip to content

Instantly share code, notes, and snippets.

@davbo
Created May 29, 2013 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davbo/5670438 to your computer and use it in GitHub Desktop.
Save davbo/5670438 to your computer and use it in GitHub Desktop.
Replaces any preloaded images with locally cached version
define(['underscore'], function(_) {
return {
replace: function (images) {
// Look for the image in our preloaded images and replace
// the path if we find it.
var preload = window.preload || {};
_.each(images, function (val, key) {
if (_.has(preload, val)) {
images[key] = preload[val];
}
});
return images;
},
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment