Standardising the way we include jQuery
22 Jun 2011 - Written by Anthony Olsen
Posted in Joomla Templates
In the past we have used our free JB Library jQuery plugin to load the jQuery library for our templates and extensions but the next version of the Zen Grid Framework (due in the next few weeks) changes all of that.
The new version of the framework will be moved from being a collection of files stored in the template folder on your site to a fully fledged Joomla system plugin which means we can incorporate most if not all of the current JB Library functionality into the Framework plugin.
This is beneficial for the end user for a few reasons, not least of which is that it will simplify the install and troubleshooting process. There will be no more need to rummage through the plugin manager to set javascript effects like back to top or lazy load and significantly in order to control the way jQuery is output on the page.
The new framework will allow the user to control all javascript effects and control the loading of the jQuery library from within the template parameters itself. This also includes nominating any scripts that you want to remove from the output of the page as per the current functionality of the JB Library.
Looking upstream and downstream
In addition to this we are also going to be implementing what is quickly becoming a standard way of checking if jQuery is loaded on the page. Yireo posted about this solution recently, and the folk at Yootheme (perhaps the originators of the technique?) have implemented the same thing in their Warp framework and Zoo extensions. Another joomla jquery plugin and other Joomla developers are implementing the technique as well.
The technique basically looks upstream (eg before the plugin has fired) to see if jQuery has loaded and if it has it doesn't do anything; while if it hasn't, it will load the version you have selected in the template parameters onto the page.
The framework will also provide the option of stripping scripts from the page that may not use this technique and have no "off switch" in their options. This way you get to ensure that your site only loads one instance of the jQuery library and therefore avoids conflicts with any 3rd party extensions.
I'll be posting more updates of feature upgrades in the Zen Grid Framework so stay tuned for more info in the coming weeks.
blog comments powered by Disqus