thewirelessguy / cornerstone

Cornerstone is a WordPress starter theme based on the Zurb Foundation Responsive Framework. Cornerstone aims to provide a lightweight starter theme that is responsive and SEO friendly that web designers can build great looking websites on.
GNU General Public License v2.0
155 stars 40 forks source link

Load jQuery in <head> #16

Open pablopaul opened 10 years ago

pablopaul commented 10 years ago

Hi @thewirelessguy , is there any specific reason why jQuery gets loaded in the head?

I suggest to move it to the bottom, ok?

klongdesigns commented 10 years ago

One issue with jQuery getting loaded in the bottom is that not all plugins use jQuery correctly. They don't wrap any code in the document.ready() function, but instead go straight to using $('element').whatever(), so if you move it to the bottom, then that script will not execute. Creating a theme that loads every script in the footer is not good practice, since you can't control all your variables. If you want to load jQuery at the bottom in your child theme, then use a function to remove Cornerstone's parent js loads and replace it with your own. Then you can load what you want where you want it.

pablopaul commented 10 years ago

In my humble opinion a theme should head to best practices, in that case it means load all scripts in the footer, especially in the case of a foundation5 theme, which aims for speed!

If somebody uses this theme with a plugin which is not following the best practice in case of script loading he can still remove the default way and use the "wrong" way in the child theme. I definitely vote for making the better case default while providing a "fall back" solution, but not vice versa: Doing it wrong and providing a fall back to make it right…