Last active
July 1, 2016 09:16
-
-
Save lackneets/e4893dd6f9aec9d863939bc2c8d7ae79 to your computer and use it in GitHub Desktop.
Fallback for lazysizes on IE8
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
window.ready=function(e){"loading"!=document.readyState?e():document.addEventListener?document.addEventListener("DOMContentLoaded",e):document.attachEvent("onreadystatechange",function(){"loading"!=document.readyState&&e()})}; | |
/* Fallback for lazysizes on IE8 */ | |
window.ready(function(){ | |
if (document.documentMode == 8) { | |
var elms = document.querySelectorAll('.lazyload'); | |
for(var i=0; i<elms.length; i++){ | |
elms[i].setAttribute('class', String(elms[i].getAttribute('class')).replace(/\s*lazyload\s*/g, ' lazyloaded ')); | |
if(elms[i].getAttribute('data-src')){ | |
elms[i].setAttribute('src', elms[i].getAttribute('data-src')); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment