jQuery Document Ready Function For WordPress

You can set up a jQuery document ready function for use with WordPress and use the jQuery library that WordPress ships with rather than use another one. Here are three ways to use jQuery document ready function with WordPress.

Usually, a jQuery document ready function is expressed as below.



jQuery document ready 1st way

WordPress loads its own jQuery library in what is known as ‘no conflict mode‘ and the $ selector or variable that defines jQuery doesn’t work with the WordPress loaded jQuery version, so it has to be expressed more like so…


// Code goes here


Here we are using jQuery at the beginning of the document ready function and then passing or binding that to the $ selector, so now anywhere else in the code you can use the $ selector.


jQuery document ready 2nd way

There is also a shorthand version of the jQuery document ready function.

jQuery(function($) {

// Code goes here


Same issue here, using the jQuery at the beginning.

jQuery document ready 3rd way

Another way is to add the document ready code is inside a Javascript function …


    $(function() {

	// Code goes here


The outer Javascript function is known as an anonymous function and jQuery is wrapped at the end, so is therefore aliased or bound to the $ selector, so in the inner function the jQuery shorthand document does not need to be aliased.

Add the Javascript where needed or register and enqueue the script for usage.


  1. Chris on March 23, 2022 at 8:32 pm

    Thanks for the jquery code. I reference this page all the time when looking for on document ready for wordpress.

  2. Owen Carver on October 3, 2020 at 5:55 am

    Where do you paste these into WordPress though?

  3. Joseph on February 18, 2020 at 9:30 pm

    Thank you so much. My laptop was about to go flying out the window!

  4. Dave Warfel on August 6, 2019 at 5:34 pm

    Super helpful! Really appreciate you taking the time to break it down.

  5. Avanti on October 20, 2018 at 8:42 am

    Thanks for the reminder and complete summary!

Leave all Comment