Optimise tight loop on foundation.js

We should avoid jQuery selector repeats. Here I have cached the $('head') calls occurring on lines 17 and 18. This improves performance in the loop.