Quantcast
Channel:
Viewing all articles
Browse latest Browse all 60

Best Practices: Optimizing Selectors

$
0
0

Here are some tips to keep in mind when using selectors:

Id selections are really fast. They are handled by document.getElementById()

// This is fast
$('#statuses .status');

//This is faster
$(‘#statuses’).find(‘.status’);

Sizzle, the jQuery selector engine works bottom-up (right to left). Be more specific on the right side of your selector rather than on the left

//GOOD
$('li.status .delete');

//BETTER
$(‘.status img.delete’);


Filed under: jQuery Tagged: jquery Selectors

Viewing all articles
Browse latest Browse all 60

Trending Articles