Title: Difference between &#8216;register&#8217; and &#8216;enqueue&#8217; a script?
Last modified: May 8, 2017

---

# Difference between ‘register’ and ‘enqueue’ a script?

 *  Resolved [cag8f](https://wordpress.org/support/users/cag8f/)
 * (@cag8f)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/difference-between-register-and-enqueue-a-script/)
 * Hi all. I’m new to JavaScript and using it with WordPress. I understand that 
   JavaScript files should be implemented using the function [wp_enqueue_script()](https://developer.wordpress.org/reference/functions/wp_enqueue_script/).
   But the description of the function reads,
 * > Registers the script if $src provided (does NOT overwrite), and enqueues it.
 * What exactly is the difference between registering the script and enqueuing it?
   And how do they relate to the ability of my PHP code to include the JS file?
 * Thanks in advance.

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

 *  [codismo](https://wordpress.org/support/users/codismo/)
 * (@codismo)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/difference-between-register-and-enqueue-a-script/#post-9108088)
 * In simplest terms, registering it only tells WordPress about it, enqueuing it
   adds it to the website.
 * If you register it you would still need to enqueue it ( by just supplying the
   name you registered it with, without supplying the URL ).
 * You can just go ahead and use the wp_enqueue_script()
 *  Thread Starter [cag8f](https://wordpress.org/support/users/cag8f/)
 * (@cag8f)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/difference-between-register-and-enqueue-a-script/#post-9108121)
 * OK thanks for that. Am I correct then, that in order to be able to include a 
   script on a page, it first needs to be enqueued and registered? If that is correct,
   what is the reason for this? It sounds like a security measure.
 * I also see that wp_enqueue_script() will take care of registering the script 
   if the $src parameter is provided.
 * Thanks.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/difference-between-register-and-enqueue-a-script/#post-9110195)
 * Not enqueued AND registered (by two different function calls), since enqueuing
   serves to register if $src is supplied. Then why have register at all? In cases
   where you need to reference the script by tag even though you do not wish to 
   always enqueue it. Mainly so you can reference it in dependency arguments. This
   serves to enqueue it without explicitly calling wp_enqueue_script() for that 
   particular script.
 * When you enqueue, it is always loaded by the page. This is not always desirable
   for every request. By registering, it is available to be enqueued, but is not
   actually enqueued unless it is needed through some other mechanism like dependencies.
   It’s just a different way to organize scripts. You don’t need it if you don’t
   want to, enqueuing will always work.
 *  Thread Starter [cag8f](https://wordpress.org/support/users/cag8f/)
 * (@cag8f)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/difference-between-register-and-enqueue-a-script/#post-9112378)
 * > Then why have register at all? In cases where you need to reference the script
   > by tag even though you do not wish to always enqueue it. Mainly so you can 
   > reference it in dependency arguments.
 * OK this is illuminating–thanks for that.

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

The topic ‘Difference between ‘register’ and ‘enqueue’ a script?’ is closed to new
replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 3 participants
 * Last reply from: [cag8f](https://wordpress.org/support/users/cag8f/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/difference-between-register-and-enqueue-a-script/#post-9112378)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
