Support » Plugin: W3 Total Cache » [Plugin: W3 Total Cache] Remote dependencies loading after minified JS

  • I’m grabbing my jQuery and jQuery UI from Google, but they are loading after the combined minified JS. How can I get the combined JS to load after my remote dependencies? I have the dependencies set up properly in my wp_register_script calls and it all works fine with the JS minify turned off.

    Or should I just load those scripts from my own server? Just trying to spread the load around.

    Anybody else using this plugin with the Google library?

Viewing 6 replies - 1 through 6 (of 6 total)
  • OK, let me ask this question in a different way: is there any way to affect where in the HTML the combined JS is placed?

    Well, I did some digging and what I’ve learned is that when JS Minify is in “auto” mode, it puts the combined JS at the top of the head. I was able to alter the plugin code to get it to place the code at the foot of the body tag, so now all my wp_localize_scripts() variables are set before the scripts are loaded.

    Getting my jQuery from Google still, but now it’s OK, because the combined JS is now loading at the end of the document.

    Plugin Author Frederick Townes


    You have to use manual mode to load remote files in W3TC in the current releases.

    Hi xnau,
    good digging in the code!
    I am actually having the same problem, but I would rather not use the manual mode, so I was wondering if you could share the patch.

    Frederick, amazing job with the plugin.
    Is there any reason to put the the minified code at the top of the head? Would it be possible to make it configurable?

    thanks guys!

    Hey guys,
    in the end I found this article from the forum and the suggestions worked.
    Now the file to modify is Minify.php and not Plugin.php, but the trick pretty much did it.



    When you keep getting an error that jquery is not loaded, you need to check this bug-report or implement Riccardo’s hack and also do the following steps.

    find the following code in Minify.php:
    if ($ext != ‘.js’ && $ext != ‘.css’) {
    return false;
    And add just below or above:
    // don’t add jquery in the cache
    if (strpos($file, “jquery.min.js”)===true) {
    return false;

    Alternatively you could choose to prevent everything that is from google-apis as these are probably cached within the browser:
    // don’t add css/js hosted by googleapis
    if (strpos($file, “”)===true) {
    return false;

    Hope this helps!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: W3 Total Cache] Remote dependencies loading after minified JS’ is closed to new replies.