skip to Main Content

Installed Fresh wordpress version 5.8
Theme active – Twenty Twentyone

Problem – Jquery library doesn’t load on front-end.

Tried to run few Jquery commands in header.php but error generates in Inspect element tool saying "Jquery is not defined". I understand by default wordpress comes bundled with Jquery which is included in wp-includes directory.

2

Answers


  1. Chosen as BEST ANSWER

    I fixed it myself.

    The Problem was related to wordpress Twenty Twentyone theme. Wordpress actually comes bundled with Jquery but the new Twenty Twentyone theme doesn't include code to enable/register Jquery. I placed a code in functions.php to register Jquery with this theme and now the Jquery is loading on frontend.

    Here is I used in functions.php

    function load_scripts(){
        wp_enqueue_script('jquery'); # Loading the WordPress bundled jQuery version.
        //may add more scripts to load like jquery-ui
    }
    add_action('wp_enqueue_scripts', 'load_scripts');
    

    The Previous wordpress theme like Twenty Sixteen , Twenty Thirteen always had this code implemented in functions.php file so we always got Jquery library loading at front-end.


  2. Typo? Jquery() vs. jQuery().

    Otherwise, try viewing source and clicking through to the linked jQuery file. The WP hosting environment could play a part here in whether the file is linking correctly.

    ** update – great you managed to sort it!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search