This question about Configuration: Answered

Jquery library doesn't load

I installed Foswiki and several extensions which use jQuery. I have JqueryPlugin installed, however, it never actually loads the .js library. As a result I get 'jQuery is not defined" errors when I load my site and the extensions try to reference the "jQuery" object. I also tried JQueryCompatibilityModePlugin, but that didn't help. What do I have to do to get jQuery to actually load?

-- ThomasAnderson - 06 Aug 2014

Use bin/configure to check that the correct version of jquery is enabled.

Go to the extensions tab on the left side bar. Then select the JQueryPlugin tab that is listed along the top. (Unfortunately they are not in apha order.) Check if there are any flagged errors. And verify that {JQueryPlugin}{JQueryVersion} has selected an available version. If you select a jquery version 2.0 or newer, then you should also select an older version using {JQueryPlugin}{JQueryVersionForOldIEs}


For a new install, the other thing it might be is an incorrect pub URL path specified in configure. Under the General Path Settings tab, verify {PubUrlPath} is the correct URL for your configuration. The web server should be able to serve files using that URL prefix. For ex. if it's set simply to /pub Then Foswiki will look for JQuery at yoursite.com/pub/System/JQueryPlugin//jquery-1.8.3.js for example. You can verify that the selected version can be loaded manually with a similar URL tailored for your system.

-- GeorgeClark - 06 Aug 2014

The pub path is correct and I can view the jquery js source files by entering the URL to the path, so there doesn't appear to be a permission issue. When I look at the source code of any page that tries to reference jQuery code, there isn't even a script tag trying to load the library code at all. That's why I believe it must be an extension problem. {JQueryPlugin}{JQueryVersion} is set to jquery-2.0.2. It was defaulted to jquery-1.8.3, but that wasn't working either, so I tried a newer version. I don't need IE 8 compatibility, so that's not a big deal, but I set that value anyway. I've also tried installing JQueryCompatibilityModePlugin, but that's not including the jQuery core code either. There must be some other setting that is causing the JS sources not to load.

-- ThomasAnderson - 07 Aug 2014

I also tried enabling MergeHeadAndScriptZones, but that didn't help either. The only script that seems to be included in the page source is blocks that look like (function($) { ... })(jQuery) or jQuery.extend... and those are failing for the undefined jQuery variable. I don't see any other javascript in there at all.

-- ThomasAnderson - 07 Aug 2014

Okay, I'm making some progress now... I disabled {Plugins}{PageOptimizerPlugin} because that was doing some source code combination stuff. However, because I'm using mod_perl, it required an apache restart to actually take effect, which I didn't realize until I saw a PageOptimizerPlugin reference in the source code still. After restarting apache, I'm now seeing script tags loading source code and the jQuery undefined problem has ceased. Now I just have various other JS errors, which I guess are not technically related to this support topic. So this one is closed. Thanks for the help.

-- ThomasAnderson - 07 Aug 2014
 

QuestionForm edit

Subject Configuration
Extension JQueryPlugin, PageOptimizerPlugin
Version Foswiki 1.1.9
Status Answered
Related Topics
Topic revision: r4 - 07 Aug 2014, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy