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