Pull Request #218: jQuery in Joomla core by jlleblanc · joomla/joomla-cms · GitHub

At J! and Beyond, we discussed ways of implementing jQuery in Joomla 3.0. Here is what we have so far:

A minified copy of jQuery 1.7.2

A file with jQuery.noConflict();

An additional method for JHtmlBehavior (would require Platfrom merge, unless we have a standard way of doing this in the CMS library)

Calling JHTML::_(‘behavior.jquery’); loads both jQuery and the separate file with noConflict. This is being done because Joomla currently loads all of the JavaScript files first, then loads all of the JavaScript declarations afterwards. If you load jQuery, then MooTools (or another file that pre-defines $), then call jQuery.noConflict(), it will not work: http://www.designvsdevelop.com/jquery-in-joomla-i-was-wrong/

This approach works, but it is sub-optimal as you have to incur the overhead of two HTTP requests. There are two workarounds we could pursue:

Manually add jQuery.noConflict(); at the end of jquery.min.js. We would have to do this every time we update jQuery. This is what WordPress does.

Add new code to JDocument and JDocumentRenderer that would allow declarations to be added immediately before or after a script is loaded. (I believe @beat mentioned he had a pull request for this on the platform)

Another thing we may want to consider is adding an option in Joomla that will let you specify a CDN copy of jQuery to use in place of the local one.

via Pull Request #218: jQuery in Joomla core by jlleblanc · joomla/joomla-cms · GitHub.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s