University Libraries

Feature Request Resolved

[4/17/15 @ 1:29 pm - Matthew]

The LibChat widget currently doesn't check to see if jQuery is already loaded on a page before loading it, causing the script to be loaded twice in several of our systems (including Summon, 360Link2.0, Ares, Illiad, etc.)

I've asked Springshare to check for jQuery support before loading the script with their widget.

[4/20/15 @ 10:02 am - Matthew]

Springshare added this to the feature request list, and asked me if I had other reasons to implement it. So I sent along this list along with a suggestion:

  1. Performance - loading jQuery twice adds an extra 35kb plus a sever request to the user's browser. This affects not only speed but also data plans.
  2. jQuery conflicts. If someone is running jQuery 2.x, when you load your jQuery 1.11.x there are a few functions that cause conflicts.
  3. No conflict mode. If you're not running jQuery in no-conflict mode, then you could cause issues with sites that are already running Prototype, or other libraries that have mapped the $ prefix. (Like 360Link from ProQuest). Likewise, if you run it in no conflict mode, you could cause conflicts in versions between my jQuery that I'm loading in 360Link in no conflict mode, if I were running a different version that you! :)

It should be as easy as adding something like this function, adapted from Karl Swedberg's jQueryify bookmarklet:

if(typeof jQuery!='undefined') {
    console.log('This page already using jQuery v'+jQuery.fn.jquery);
} else if (typeof $=='function') {
    $jq=jQuery.noConflict(); // Use $jq in script instead of $

I will update on that status of this once I hear back from Springshare.

[4/20/15 @ 1:41 pm - Matthew]

I took a closer look at Springshare's code, and they are testing for jQuery before they load it with window.jQuery (lines cf. 28). I suspect the issue is that because ProQuest is loading both Prototype (why?!?) and jQuery on 360Link, and running jQuery in no conflict mode, the global jQuery & $ variables are somehow registering as undefined when Springshare's widget queries them. (This article might give some insight.)

Not sure if this can be addressed, since it's a specific case to how two versions of jQuery get loaded when one product is used on another product page, but I'll keep tinkering with it.

[4/21/15 @ 11:17 am - Matthew]

Since there is no way for me to load the relevant LibChat script after ProQuest loads jQuery until ProQuest fixes their 360Link 2.0 "Custom JavaScript" function, LibChat is checking for jQuery before the other version loads. I'm closing this out as a Springshrare issue, and moving it to the Link Resolver.

This issue was reported on 4/17/15 and resolved on 4/21/15.