Skip to content

Instantly share code, notes, and snippets.

@tut-tuuut
Created November 16, 2012 10:56
Show Gist options
  • Save tut-tuuut/4086399 to your computer and use it in GitHub Desktop.
Save tut-tuuut/4086399 to your computer and use it in GitHub Desktop.
Tentative d'optimisation des sélecteurs de type jQuery('#truc')
var $_ = function(id) {
return jQuery(document.getElementById(id));
}
var i = 0;
var limit = 25000;
console.time('montruc');
for (i = 0; i < limit; i++) {
$_('article-head');
}
console.timeEnd('montruc'); // 316ms
console.time('simple');
for (i = 0; i < limit; i++) {
$('#article-head');
}
console.timeEnd('simple'); // 468ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment