Created
September 29, 2016 22:18
-
-
Save holloway/0e284240f48888b2444c90202024c8b5 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
## Cache your selectors | |
Don't do this: | |
```JavaScript | |
$("body").on("click", function() { | |
$("body").addClass("clicked"); | |
}); | |
``` | |
Do this: | |
```JavaScript | |
var $body = $("body"); | |
$body.on("click", function() { | |
$body.addClass("clicked"); | |
}); | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment