1. V3 Knowledge Base
  2. Advanced Technical Use Cases

jQuery conflicts

Justuno uses jQuery for much of it's embed code processing because it's both a stable library and because over 97% of all websites already load jQuery. Justuno approached the use of jQuery with that adoption in mind and specifically wrote our embed code to not load it if it's already loaded on the website.

Whenever we do need to load our own jQuery library, we do so in a delicate manner that for the most part eliminates any conflicts.

Here is a break down of the flow we use to check for existing jQuery libraries and to load our own if necessary.

- IF (jQuery exists and is an acceptable version) THEN -
Assign jju = existing jQuery
- ELSE -
Load our own jQuery from our CDN servers (currently v3.3.1)
Once loaded, Assign jju = jQuery.noConflict(true);
- END IF -

The "noConflict" portion of that above flow ensures that any other library already on the site that assigns $ and jQuery variables will stay that way and won't be overwritten by our new jQuery load.

The above method almost always does the trick. There is however some scenarios where there may still be a conflict because of the timing between Justuno loading and other jQuery scripts on your website. This is what we call a race condition.

For that reason we did make a config property that you can set somewhere above the Justuno Embed code that will force Justuno to wait for your own jQuery library and to use it only. This will of course break Justuno if your site doesn't load jQuery on the same page Justuno is loaded.

Here is how to force Justuno to use your own jQuery only:

<script>ju_options = {forcejquery:false};</script>