Support » Plugin: TablePress » Uncaught ReferenceError: jQuery is not defined

  • Resolved vitruvian1man

    (@vitruvian1man)


    If I’m logged-in to WordPress and visit the page, the the table functions as described (sortable, etc.). However, if I log-out and visit the page as a random visitor, then none of the dynamic features of the table are available.

    This is the error when I inspect using the console:

    Uncaught ReferenceError: jQuery is not defined
        at (index):1048
    jquery-migrate.min.js?ver=3.3.2:2

    I read some of the troubleshooting for this particular error, “Uncaught ReferenceError: jQuery is not defined” and tried to fix it but have not made any progress.

    As a newbie, I performed some of the suggestions that others shared in their various support queries:

    * In Autoptimize, I added exclusions such as js/jquery/jquery.js and plugins/tablepress, but these didn’t help.

    * Disabled Autoptimize and that didn’t help. Each time I checked the webpage, it generated that same error, “Uncaught ReferenceError: jQuery.”

    * Disabled Wp Super Cache, but that didn’t help

    * Installed and tested jQuery Migrate, but it didn’t find any problems

    * WordPress 5.6 and Astra (pro) theme are being used

    If anybody has a suggestion, then let me know.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    That’s strange, as the jQuery file is indeed loaded… Can you please turn off the jQuery Migrate Helper plugin, so that I can see the problem without this being on?

    Regards,
    Tobias

    Thread Starter vitruvian1man

    (@vitruvian1man)

    I appreciate such a timely followup. I just deactivated and then deleted jQuery Migrate Helper plugin.

    Update as of Fri. 01Jan2020 12:20pm ET USA:

    After I deactivated all plugins and cleared cache and then tested tablepress, the same error in the console was generated.

    The website’s theme is Astra – pro – child theme and I believe it has had some custom code put into a child functions.php file, not sure whether that could be interfering with tablepress.

    Also, this is the other info about the setup that I overlooked providing in my initial inquiry:

    · Website: [reference prior link provided to the blog post that is using a table by tablepress]
    · TablePress: 1.12
    · TablePress (DB): 41
    · TablePress table scheme: 3
    · Plugin installed: 2020/12/29 19:32:06
    · WordPress: 5.6
    · Multisite: no
    · PHP: 7.4.13
    · mysqli Extension: true
    · mySQL (Server): 10.3.27-MariaDB-log-cll-lve
    · mySQL (Client): 10.3.27
    · ZIP support: yes
    · UTF-8 conversion: yes
    · WP Memory Limit: 40M
    · Server Memory Limit: 1M
    · WP_DEBUG: false
    · WP_POST_REVISIONS: true

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    I just noticed that the jQuery library is loaded with the defer='defer' attribute, to delay the loading of the JS file.
    This is non-standard behavior in WordPress, so that your theme or another plugin is adding this. It’s however causing this problem.
    Can you please check what’s adding this and then turn that off?

    Regards,
    Tobias

    Thread Starter vitruvian1man

    (@vitruvian1man)

    Thank you for identifying the problem. I will take some time to figure out where the defer='defer' is being added and then remove it. I’ll mark this support request as resolved, too.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    it’s likely a plugin or your theme, so I would start looking there. For a test, you could temporarily deactivate plugins or switch the theme.

    Regards,
    Tobias

    Thread Starter vitruvian1man

    (@vitruvian1man)

    I looked into the theme, which is using a child theme. In the child theme folder, I reviewed the functions.php file and it had some code in it to defer javascript. So, I removed it and tablePress works perfectly with all the dynamic features.

    Anyway, here’s the snippet of code that I removed:

    // Defer Parsing of JavaScript in WordPress via functions.php file
    // Learn more at https://technumero.com/defer-parsing-of-javascript/ 
    
    function defer_parsing_js($url) {
    //Add the files to exclude from defer. Add jquery.js by default
        $exclude_files = array('jquery.js');
    //Bypass JS defer for logged in users
        if (!is_user_logged_in()) {
            if (false === strpos($url, '.js')) {
                return $url;
            }
    
            foreach ($exclude_files as $file) {
                if (strpos($url, $file)) {
                    return $url;
                }
            }
        } else {
            return $url;
        }
        return "$url' defer='defer";
    
    }
    add_filter('clean_url', 'defer_parsing_js', 11, 1);

    Thanks again for your guidance and solution.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, that’s indeed it! 🙂 Nice find!
    Good to hear that everything is working again!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

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