s9y/Serendipity — pull request #113 by levito (2014-04-14 21:12:56+00:00)
Title: js performance improvement: less DOM firing

Let's fire less into the DOM.

$('body').has('#foo').size() > 0 means:

1. Find all 'body's
2. Go down the DOM until you find a '#foo' in it
3. Count all 'body's which had '#foo' in it, with an extra function call
4. More than 0? Go on!

$('#foo').length just does the same much faster:

1. Find all '#foo's
2. Is the resulting list greater than 0? (no function call) Go on!