Created
March 13, 2014 22:58
-
-
Save veltman/9538964 to your computer and use it in GitHub Desktop.
jQuery caching
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
//Return a cached selection if it's been used, | |
//Otherwise get the jQuery selection and cache it | |
var $$ = function(x) { | |
if (!this[x]) this[x] = $(x); | |
return this[x]; | |
} | |
$$("div.test").html("a"); | |
$$("div.test").html("b"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment