home > textual > blog > technical > Joomla and jQuery
Joomla and jQuery
technical
Sunday, 31 January 2010 10:52

As I've mentioned previously, I am absolutely in love with jQuery, and have been using and abusing the hell out of it in my day-job, and have even been spending my leisure time reading everything I can get into my beady little eyes on the subject of jQuery.  It, combined with continually advancing versions of HTML, XHTML, and CSS, is helping to make the web a better place for both developers and designers.  I've all but discontinued using Flash.  I'm still using it as a media player and for occasional other necessary applications, but with HTML-5's implementation of the <audio> and <video> tags, I can see myself using it less and less over time.

I'm also a huge Joomla junkie.  Since I discovered it a few years ago, it has been the foundation of nearly every site I have built, outside of my day-job, of course.  I recommend it to nearly every one of my freelance clients, and pretty much dig it all-around.

New Woodrush Site DesignI've been working on a new design for the Woodrush website, which is to simply be a new template for the current Joomla-based site. Of course, my new-found love of jQuery was being heavily considered in the design.  Although I'd seen jQuery mentioned in some Joomla extensions, I'd never done any real research on the subject.  So once I finished the design and got the go-ahead from the band-mates, I decided that I needed to know a bit about how jQuery integrates into Joomla.

The first thing I found out was that Joomla relies heavily on another JS library, MooTools.  I know it's used a lot in the administrative back-end of a Joomla site, and I know it's loading into a lot of pages because of extensions that use it, but it isn't natively used in the front-end by the standard extensions.

I also found out that jQuery uses the same coding shortcut ('$') as many other JS libaries, like MooTools, and therefore must be put into a special no-conflict mode to work, and that all my jQuery code must be written without the shortcut, or within a self-contained enclosure where the shortcut is only used within the enclosure.  If you don't understand, don't worry, you probably don't need to.  If you kinda understand, and want to understand more, read the jQuery API page on No Conflict mode.

So, now that I know this, and I know how to ensure that all of my jQuery code will in theory work in the Joomla environment, I am ready to progress with the next step of building the site.

But this brings up a question: why can't I pick my default JS library in Joomla's front end?  I understand that, when the foundations for Joomla were built, back when it was called 'Mambo', there was no jQuery, and MooTools was the bomb-diggity in the world of JS Libraries.  But, as we've seen time and time again, every empire must fall.  jQuery may be the best thing around right now, but who knows where it will be in a decade?  And so, I wonder if the future of Joomla, and all forthcoming CMS-es, might include the ability to select your own preferred default JS Library, whether included with the CMS or installed afterwards as an extension?

So, CMS designers of the future... consider me this: default libraries are cool, but gimme some options to override.  I can override almost everything else, so why not this?  I mean, seriously... why?