bltcoffee/scripts/index.js
2018-09-09 09:58:47 -07:00

24 lines
631 B
JavaScript

(function () {
// Defer image loading till last.
function init() {
var imgDefer = document.getElementsByTagName('img');
for (var i = 0; i < imgDefer.length; i++) {
if (imgDefer[i].getAttribute('data-src')) {
imgDefer[i].setAttribute('src', imgDefer[i].getAttribute('data-src'));
}
}
}
// When the DOM is ready it'll execute fn().
function ready(fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
window.onload = init;
})();