Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter animalapp

    (@animalapp)

    Debug Info:

    ### WordPress Environment ###
    Home URL: https://animalapp.co
    Site URL: https://animalapp.co
    WP Version: 5.5.1
    CCJ Version: 4.21.3
    WP Multisite: false
    WP Memory Limit: 256M
    
    ### All codes ###
    Array
    (
        [all] => Array
            (
                [0] => 761.js
                [1] => 753.js
                [2] => 715.js
                [3] => 714.js
                [4] => 712.js
                [5] => 711.js
                [6] => 710.js
                [7] => 709.js
                [8] => 685.js
            )
    
    )
    ### Search tree ###
    Array
    (
        [5] => Array
            (
                [frontend-js-header-internal] => Array
                    (
                        [0] => 761.js
                        [1] => 753.js
                        [2] => 715.js
                        [3] => 714.js
                        [4] => 712.js
                        [5] => 711.js
                        [6] => 710.js
                        [7] => 709.js
                        [8] => 685.js
                    )
    
            )
    
    )
    Plugin Author SilkyPress

    (@diana_burduja)

    By default the jQuery library is loaded in the header. On your website it is loaded in the footer. This leads to the “jQuery is not defined” error messages.

    You have two options:
    1. set your custom JS scripts to load in the footer
    or
    2. search for the plugin or the PHP snippet that moves the jQuery to the footer and make it load in the header.

    I also notice that any of the theme’s JS/CSS files on your website are bundled in a “/_static/” folder instead of the typical “/wp-content/themes/your-theme/” folder. That probably also has to do with the jQuery being loaded in the footer. Do you use some CSS/JS optimization plugin for that?

    Thread Starter animalapp

    (@animalapp)

    Hello Diana, first thanks for your quick reply, is aw it immediatley but held from replying until i tested your suggestions.

    1. I disabled all plugins except the bare minimums, i only had one optimization plugin which my wordpress subscription installed by default called “Page Optimize” by Automattic. I disabled it and everything which was not bare bone while on that task and it had no effect.

    2. Setting the custom js to load in the footer rather than the header actually worked! for every page except 2:
    a. animalapp.co/profile
    b. animalapp.co/logout
    I have no idea specifically why these two pages continue with the error, i tried loading them on the header just in case and it had the same effect so I proceeded to try your 2nd solution:

    3. “search for the plugin or the PHP snippet that moves the jQuery to the footer and make it load in the header.” I’m new to wordpress, we used to just handle the entire backend and front end ourselves, so my knowledge is limit here and I honestly have no clue how to do this, i tried going through the themes files and did not find anything.

    Switching the scripts to the footer worked for all other pages, I could not isolate why those 2 pages specifically still have the same error.

    P.S I also tried switching to an entirely different theme to see if it had any effect and it didn’t.

    Plugin Author SilkyPress

    (@diana_burduja)

    On both the “animalapp.co/profile” and the “animalapp.co/logout” pages you’re logged in. In your first message you said that the error shows up only in the frontend, when not logged in.

    What JS error do you get on these two pages?

    Thread Starter animalapp

    (@animalapp)

    I get the same error, Jquery not defined

    Plugin Author SilkyPress

    (@diana_burduja)

    A quick search in a search engine showed me only PHP snippets as solutions for moving the jQuery in the footer.

    For example: this, or this, or this, or this.

    Could you check in the child theme’s functions.php file for a PHP snippet similar to the ones in the linked tutorials? Or in the theme’s functions.php file.

    Thread Starter animalapp

    (@animalapp)

    Diana, first of all, top support, on point and quick response, appreciate it very much.

    Trying the first link you provided: http://biostall.com/how-to-load-jquery-in-the-footer-of-a-wordpress-website/
    I was prompted to add the following code:
    view plaincopy to clipboardprint?

    function my_init()   
    {  
        if (!is_admin())   
        {  
            wp_deregister_script('jquery');  
      
            // Load the copy of jQuery that comes with WordPress  
            // The last parameter set to TRUE states that it should be loaded  
            // in the footer.  
            wp_register_script('jquery', '/wp-includes/js/jquery/jquery.js', FALSE, '1.11.0', TRUE);  
      
            wp_enqueue_script('jquery');  
        }  
    }  
    add_action('init', 'my_init');

    to the functions.php file found through the theme editor. Doing this PLUS setting the scripts on the footer seems to have fixed everything. Thanks again.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Jquery not working when logged off wp-admin’ is closed to new replies.