Reputation: 27
I am creating joomla templates and want to add a simple jquery script. The problem is that there are other joomla extensions like GCalendar which load their own jquery.
This means:
<script src="http://code.jquery.co....
it will conflict with the jquery of other extensionsAny ideas?
Upvotes: 0
Views: 889
Reputation: 63522
You can check if jQuery
is defined in script and load it if it has not been loaded prior.
You may run into functionaliy issues if the previously loaded version of jQuery is not a version you are supporting
<script>window.jQuery || document.write(
'<script src="/scripts/jquery-1.6.2.min.js"><\/script>')
</script>
Upvotes: 1
Reputation: 6260
If you are hosting the library yourself you could wrap the entire library with an
if ( !jQuery ) {
// jQuery Library
}
Or you could look into a library like RequireJS to handle your dependencies.
Upvotes: 1