Created
October 10, 2013 05:59
-
-
Save synzhang/6913712 to your computer and use it in GitHub Desktop.
Javascript Lazy Loading
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
| <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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment