Created
September 17, 2010 14:23
-
-
Save draggor/584300 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>index</title> | |
<meta name="generator" content="TextMate http://macromates.com/"> | |
<meta name="author" content="arcus"> | |
<!-- Date: 2010-08-04 --> | |
<script src="jquery.js" type="text/javascript" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$.noConflict(); | |
// Cache Holder | |
var cachey_cache = {}; | |
var $ = function(sel) { | |
if(sel instanceof Function) { | |
return jQuery(sel); | |
} | |
var arg2 = arguments[1]; | |
if (cachey_cache[sel]) { | |
// If selector esists return the cached version | |
return cachey_cache[sel]; | |
} else { | |
// Otherwise return the selected object and add it to the cache holder | |
return cachey_cache[sel] = jQuery(sel); | |
} | |
}; | |
// Testing Code | |
$(function() { | |
alert($("#test").html()); | |
alert($("#test").html()); // This selection will be cached | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="test">hello world</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment