Created
January 7, 2010 04:40
-
-
Save hisasann/270994 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>untitled</title> | |
<script src="lib/jquery.js" type="text/javascript" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8" id="lazy1"> | |
/* | |
// Make sure you strip out (or replace) comment blocks in your JavaScript first. | |
window.lazy = function() { | |
alert("lazy!!"); | |
} | |
*/ | |
</script> | |
<script type="text/javascript" charset="utf-8" id="lazy2"> | |
/* | |
lazy(); | |
*/ | |
</script> | |
<script type="text/javascript" charset="utf-8"> | |
// jLazyLoader | |
// 後からJavaScriptをロードするためのjQueryPlugin | |
(function($) { | |
$.jLazyLoader = function() {} | |
$.jLazyLoader.load = function(selector) { | |
load(selector); | |
} | |
function load(selector) { | |
eval(stripOutCommentBlock($(selector).html())); | |
} | |
// [via] http://d.hatena.ne.jp/kagigotonet/20091221/1261355472 | |
function stripOutCommentBlock(code) { | |
return code.replace(/^[\s\xA0]+\/\*|\*\/[\s\xA0]+$/g, "") | |
} | |
})(jQuery); | |
// DCL | |
$(function() { | |
$("#lazyLoader").click(function() { | |
$.jLazyLoader.load("#lazy1"); | |
$.jLazyLoader.load("#lazy2"); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="lazyLoader"> Lazy Load </div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment