From: Jack Mahoney Date: Thu, 13 Feb 2014 00:49:37 +0000 (+1100) Subject: Optimized selectors in another tight loop X-Git-Tag: v5.2.0~54^2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4435%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Optimized selectors in another tight loop Found another selector repeat inside of a tight loop. Cached the selector before entering loop --- diff --git a/js/foundation/foundation.js b/js/foundation/foundation.js index ad3385303..c02ddf70a 100644 --- a/js/foundation/foundation.js +++ b/js/foundation/foundation.js @@ -73,10 +73,11 @@ var header_helpers = function (class_array) { var i = class_array.length; + var head = $('head'); while (i--) { - if($('head').has('.' + class_array[i]).length === 0) { - $('head').append(''); + if(head.has('.' + class_array[i]).length === 0) { + head.append(''); } } };