Skip to content

Instantly share code, notes, and snippets.

@remy
Created December 14, 2009 00:01
Show Gist options
  • Save remy/255680 to your computer and use it in GitHub Desktop.
Save remy/255680 to your computer and use it in GitHub Desktop.
<!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