Created
December 14, 2009 00:01
-
-
Save remy/255680 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Lazy Eval Technique</title> | |
</head> | |
<body> | |
<script id="lazy"> | |
/* | |
alert('lazy module loaded'); | |
*/ | |
</script> | |
<script> | |
function lazyLoad() { | |
var lazyElement = document.getElementById('lazy'), | |
lazyElementBody = lazyElement.innerHTML, | |
jsCode = stripOutCommentBlock(lazyElementBody); | |
eval(jsCode); | |
} | |
function stripOutCommentBlock(str) { | |
return str.replace(/\/\*/, '').replace(/\*\//, ''); | |
} | |
</script> | |
<div onclick="lazyLoad">Lazy Load</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment