Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial proof of concept for JavaScript libraries plugin #110

Closed
wants to merge 29 commits into from

Conversation

jlleblanc
Copy link
Member

This is a working proof of concept, with one major missing feature: Currently no way of designating libraries as CDN copies, nor is there any "CDN mode." We might possibly assume that anything beginning with 'http' is a CDN version, but then we will also need to keep track of the minimum local version and the minimum remote version.

*
* @return boolean
*/
static public function jquery_loaded()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we generalize this as a is_loaded() function with an arguement for library?

is_loaded('mootools') or is_loaded('jquery') for example, if we use the filenames as determinants for what the files contain.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnomeontherun so here's the intent: the jQuery one is definitely a special case where we're cycling through the header and doing a brute lookup to make a determination. The MooTools one (if we add it) would be there to determine if Joomla has loaded its own copy of MooTools; this would be for replacing it with a CDN copy. In all other cases, we're counting on this plugin to catch on and people just use it rather than try to do a brute search.

As we discussed on the side, it would be a good idea to take the functionality of jquery_loaded() and generalize it as something like loaded('jquery'), which would allow you to specify the brute search term.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now added a library_loaded() function that generalizes checking for libraries in the head section (among a few other features).

@jlleblanc
Copy link
Member Author

Added a mechanism for automatically adding jQuery.noConflict() immediately after jQuery is loaded, as seen in www.designvsdevelop.com/jquery-in-joomla-i-was-wrong/

@gnomeontherun
Copy link
Member

Is there any reason you might want to not use noConflict and if another script already calls it is there any reason calling it more than once can hurt?

Makes an instance of mod_version by default (square-one#112)
Makes current version info available, showing both Square One and Joomla versions (square-one#108)
@jlleblanc
Copy link
Member Author

Possibly. If you know for sure that you're not loading another library that uses $ (MooTools, Zepto, etc...), you might prefer to use $ instead of wrapping everything in a closure. You might also have some edge case where you need to debug and don't want to call noConflict.

I don't think calling it twice hurts, but the script is only being added once the manager confirms that jQuery hasn't already been loaded.

Regardless, I'll add a flag allowing someone to opt-out of noConflict().

On Mar 10, 2012, at 10:32 AM, Jeremy Wilken wrote:

Is there any reason you might want to not use noConflict and if another script already calls it is there any reason calling it more than once can hurt?


Reply to this email directly or view it on GitHub:
#110 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants