Title: jQuery(document).ready not working
Last modified: October 19, 2020

---

# jQuery(document).ready not working

 *  Resolved [michalrama](https://wordpress.org/support/users/michalrama/)
 * (@michalrama)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/jquerydocument-ready-not-working/)
 * Hello,
 * When I create a JS file with code `console.log(123);`, it works.
 * However, if I add
 *     ```
       jQuery(document).ready(function($) {
          console.log(456);
       });
       ```
   
 * only **123** will print it. I found that the site loads jquery (version 1), but
   even if I create HTML file with code
 * `<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"
   ></script>`
 * it has no effect.
 * What is the correct syntax, please?
 * Thank you
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjquerydocument-ready-not-working%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/jquerydocument-ready-not-working/#post-13558233)
 * You don’t need to load the jQuery library again. By default all WordPress websites
   load the jQuery 1.12.4 version. See the 203 line in your website’s homepage HTML:
   `
   <script type='text/javascript' src='https://your-website/wp-includes/js/jquery/
   jquery.js?ver=1.12.4-wp' id='jquery-core-js'></script>`
 * The
 *     ```
       jQuery(document).ready(function($) {
           console.log(456);
       });
       ```
   
 * code will not be executed because it is set to execute after the code in the 
   theme’s public.js file and there is an error about a missing $(…).live function
   in the public.js file.
 * The `console.log(123);` code will be executed before the DOM is built and before
   the jQuery library or the public.js file is loaded, therefore it works.
 * You need to solve the missing $(…).live function, then your jQuery code will 
   work.
    -  This reply was modified 5 years, 7 months ago by [SilkyPress](https://wordpress.org/support/users/diana_burduja/).
    -  This reply was modified 5 years, 7 months ago by [SilkyPress](https://wordpress.org/support/users/diana_burduja/).
    -  This reply was modified 5 years, 7 months ago by [SilkyPress](https://wordpress.org/support/users/diana_burduja/).
    -  This reply was modified 5 years, 7 months ago by [SilkyPress](https://wordpress.org/support/users/diana_burduja/).
    -  This reply was modified 5 years, 7 months ago by [SilkyPress](https://wordpress.org/support/users/diana_burduja/).
 *  Thread Starter [michalrama](https://wordpress.org/support/users/michalrama/)
 * (@michalrama)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/jquerydocument-ready-not-working/#post-13559467)
 * Hello,
 * Yes. You’re right. Thank you for the quick reply.
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/jquerydocument-ready-not-working/#post-13559562)
 * You’re welcome 🙂
 *  [Atanas Yonkov](https://wordpress.org/support/users/nravota12/)
 * (@nravota12)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/jquerydocument-ready-not-working/#post-13570959)
 * Hi [@diana_burduja](https://wordpress.org/support/users/diana_burduja/) ,
 * I am a theme author. WordPress does not load jQuery on frontend by default. It
   only loads it, if the theme / or a plugin has enqueued a jquery script, like 
   so:
 * `wp_enqueue_script( 'custom-js', get_template_directory_uri() . '/assets/js/custom.
   min.js', array( 'jquery' ),'',true);`
 * More and more themes prefer to use vanilla js in their code, this means jQuery
   is not called on the website! Please check my theme [Highstarter](https://wordpress.org/themes/highstarter/)
   for reference (disable all active plugins, because any of them might be loading
   jQuery, then try adding jquery code via Simple Custom CSS and JS plugin). I have
   the same problem as [@michalrama](https://wordpress.org/support/users/michalrama/),
   jQuery code not working because jQuery is no defined.
 * You need to add a check in your plugin to enqueue jQuery automatically if the
   user uses it in the code snippet from your plugin.
 *     ```
       jQuery(document).ready(function($) {
           //Code
       });
       ```
   
 * Please consider adding this to the plugin, this is really important because more
   and more themes do not use jQUery and a lot of non-tech users ask me for suppport
   because they cannot figure out why their jquery script does not work in my theme.
   I will also list this as a seperate thread. Cheers and take care!
    -  This reply was modified 5 years, 7 months ago by [Atanas Yonkov](https://wordpress.org/support/users/nravota12/).
    -  This reply was modified 5 years, 7 months ago by [Atanas Yonkov](https://wordpress.org/support/users/nravota12/).
    -  This reply was modified 5 years, 7 months ago by [Atanas Yonkov](https://wordpress.org/support/users/nravota12/).

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

The topic ‘jQuery(document).ready not working’ is closed to new replies.

 * ![](https://ps.w.org/custom-css-js/assets/icon-128x128.png?rev=1303730)
 * [Simple Custom CSS and JS](https://wordpress.org/plugins/custom-css-js/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-css-js/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-css-js/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-css-js/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-css-js/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-css-js/reviews/)

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [js](https://wordpress.org/support/topic-tag/js/)

 * 4 replies
 * 3 participants
 * Last reply from: [Atanas Yonkov](https://wordpress.org/support/users/nravota12/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/jquerydocument-ready-not-working/#post-13570959)
 * Status: resolved