Skip to content

Instantly share code, notes, and snippets.

@hisasann
Created January 7, 2010 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisasann/270994 to your computer and use it in GitHub Desktop.
Save hisasann/270994 to your computer and use it in GitHub Desktop.
<!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