Created
June 6, 2014 16:59
-
-
Save steveosoule/762eb5c9cd3313b6fde9 to your computer and use it in GitHub Desktop.
Lazy Load JavaScript
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
<!-- FROM: http://googlecode.blogspot.com/2009/09/gmail-for-mobile-html5-series-reducing.html --> | |
<html> | |
... | |
<script id="lazy"> | |
// Make sure you strip out (or replace) comment blocks in your JavaScript first. | |
/* | |
JavaScript of lazy module | |
*/ | |
</script> | |
<script> | |
function lazyLoad() { | |
var lazyElement = document.getElementById('lazy'); | |
var lazyElementBody = lazyElement.innerHTML; | |
var jsCode = stripOutCommentBlock(lazyElementBody); | |
eval(jsCode); | |
} | |
</script> | |
<div onclick=lazyLoad()> Lazy Load </div> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment