WEBSITE DESIGN

jQuery

Article by:
Date Published:
Last Modified:

Preventing jQuery From Loading More Than Once

There are many times when, because you are including 3rd party files, jQeury may get loaded more than once. This is not recommended, and loading jQuery again wipes all the jQuery environment variables, which can break things.

Here is a easy way to only load jQuery if it has not already been loaded.

1
2
3
<script>
    window.jQuery || document.write('<script src="js/jquery.min.js">')
</script>

Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Related Content:

Tags

comments powered by Disqus