Programming
How to check if jQuery is already loaded in Magento

If you are building some custom extension for Magento and your extension includes jQuery, but you don’t want to load it if its already loaded by some other Magento extension or theme, then you can do so using your layout XML file as shown below. Here we are checking for the global window.jQuery variable. If that is undefined jQuery is not loaded yet. Add the following to your modules layout XML.

This will be included in the head after all other javascripts are loaded and you can be sure jQuery wasn’t included if its already there.

Tag

Related Post

Leave a Reply