I had lot of confusion earlier while enqueuing or dequeuing a script in wordpress. I was not sure which function to use and would just keep on using various functions on a trail and error basis.

Hope below points would help to clarify atleast a few things with regards to when we should use a particular function


This just registers the script but does not actually queue it for execution


This is used to enqueue a script which is required to be executed on our template. A script can be enqueued without registering it i.e. without using wp_register_scripts.


This is an action which prints/outputs/shows up the scripts on our template for execution

When to use wp_register_script

You may be wondering why would I use wp_register_scripts and why not just directly use wp_enqueue_scripts

The answer to that is if you are developing a custom plugin and wish to execute a script only on certain pages then it helps to just register the script and then programatically enqueue it on the required pages.


Leave a Reply

Your email address will not be published. Required fields are marked *