Skip to content

Instantly share code, notes, and snippets.

@enovav
Created July 9, 2011 11:49
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 enovav/1073542 to your computer and use it in GitHub Desktop.
Save enovav/1073542 to your computer and use it in GitHub Desktop.
Mobile Images
if (screen.width < 480) {
var imgs = document.getElementsByTagName("img");
for (var i = 0; i < imgs.length; i++) {
var elm = imgs[i];
if (elm.getAttribute("data-src-mobile")) {
elm.setAttribute("src", elm.getAttribute("data-src-mobile"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment