Created
March 5, 2017 18:57
-
-
Save JMPerez/e8496fca2063a7cb811ded3d1f6a92e9 to your computer and use it in GitHub Desktop.
This file contains 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
// draw the data-uri image on the canvas | |
function a(e) { | |
if (e.getAttribute("data-src")) { | |
var t = new Image; | |
t.src = e.getAttribute("data-src"); | |
var i = e.getAttribute("width") | |
, n = e.getAttribute("height") | |
, o = e.getContext("2d"); | |
t.addEventListener("load", function() { | |
o.drawImage(t, 0, 0, i, n) | |
}, false) | |
} | |
} | |
// go through all canvas on the page with a data-src | |
function r() { | |
var e = document.querySelectorAll("canvas[data-src]"); | |
d.insertionQ("canvas[data-src]").every(function(e) { | |
a(e) | |
}), | |
[].forEach.call(e, a) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment