Skip to content

Instantly share code, notes, and snippets.

@geelen
Forked from anonymous/preload_images.js
Created April 29, 2013 02:03
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 geelen/5479309 to your computer and use it in GitHub Desktop.
Save geelen/5479309 to your computer and use it in GitHub Desktop.
(function () {
'use strict';
var i, image, j, matches, rules, sheet;
for (i = 0; i < document.styleSheets.length; ++i) {
sheet = document.styleSheets[i];
if (sheet.rules) {
for (j = 0; j < sheet.rules.length; ++j) {
rules = sheet.rules[j];
if (rules.style && rules.style.backgroundImage) {
matches = rules.style.backgroundImage.match(/url\((.*)\)/);
if (matches) {
image = new Image;
image.src = matches[1];
}
}
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment