Support » Plugin: WP Fastest Cache » jQuery is not defined

  • Resolved GeddeDev

    (@ggedde)


    This is a duplicate of https://wordpress.org/support/topic/jquery-is-not-defined-32/

    However, the issue still exists.
    My theme does not require jQuery, however when I am logged in the Admin toolbar contains the “Clear Cache” menu item with functional buttons which requires jQuery. Since I am not loading jQuery I get an error when logged in viewing my theme.

    I do not want to load jQuery as it is not needed for my theme nor is it needed for anything else on the front end of my website.

    Like “Zahnbuersten Test” suggests I thing the best thing would be for your plugin to add the jquery dependency when registering the “wp-fastest-cache/js/toolbar.js” file.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Emre Vona

    (@emrevona)

    can you send me a screenshot of the error with full screen please?

    Thread Starter GeddeDev

    (@ggedde)

    Here is the error
    “Uncaught ReferenceError: jQuery is not defined
    at toolbar.js?ver=1601345801:118”

    Here is a Screenshot:
    2020-09-28_19-23-26.png

    The issue is that your js file “/wp-content/plugins/wp-fastest-cache/js/toolbar.js” is referencing jQuery. The Error is coming from line 118, but you reference jQuery a few other times in the file.
    However, when you are registering the toolbar js file you are not specifying that jquery is a dependency. So you just need to add the jquery dependency.

    So in “/wp-fastest-cache/inc/admin-toolbar.php”
    Change:

    public function load_toolbar_js(){
        wp_enqueue_script("wpfc-toolbar", plugins_url("wp-fastest-cache/js/toolbar.js"), array(), time(), true);
    }

    To

    public function load_toolbar_js(){
        wp_enqueue_script("wpfc-toolbar", plugins_url("wp-fastest-cache/js/toolbar.js"), array('jquery'), time(), true);
    }
    • This reply was modified 1 year, 7 months ago by GeddeDev.
    Plugin Author Emre Vona

    (@emrevona)

    thank you so much 🙂 I changed as below.

    https://plugins.trac.wordpress.org/changeset/2390139/wp-fastest-cache/trunk/inc/admin-toolbar.php

    • This reply was modified 1 year, 7 months ago by Emre Vona.
    Thread Starter GeddeDev

    (@ggedde)

    Awesome!
    I just checked for updates, but nothing yet, I will check again tomorrow.

    Plugin Author Emre Vona

    (@emrevona)

    I did not release a new version. I will release it tomorrow.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘jQuery is not defined’ is closed to new replies.