]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Optimise tight loop on foundation.js 4426/head
authorJack Mahoney <jackmahoney212@gmail.com>
Wed, 12 Feb 2014 03:31:51 +0000 (14:31 +1100)
committerJack Mahoney <jackmahoney212@gmail.com>
Wed, 12 Feb 2014 03:31:51 +0000 (14:31 +1100)
We should avoid jQuery selector repeats. Here I have cached the $('head') calls occurring on lines 17 and 18

js/foundation/foundation.js

index 666e18bf82e553b24946550d741d13d4b5a5cbd7..ad33853038d13dedafb686aa229c6d8d729c9648 100644 (file)
 
   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('<meta class="' + class_array[i] + '">');
+      if(head.has('.' + class_array[i]).length === 0) {
+        head.append('<meta class="' + class_array[i] + '">');
       }
     }
   };