Skip to content

Instantly share code, notes, and snippets.

@calvindavis
Created April 10, 2013 12:43
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 calvindavis/5354279 to your computer and use it in GitHub Desktop.
Save calvindavis/5354279 to your computer and use it in GitHub Desktop.
Caching jQuery objects.
// Don't do this:
for (var i = 0; i < 100; i += 1) {
$("#foo").text(i);
}
// Do this instead:
var $foo = $("#foo");
for (var i = 0; i < 100; i += 1) {
$foo.text(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment