Title: Initializing jQuery Scripts
Last modified: August 21, 2016

---

# Initializing jQuery Scripts

 *  Resolved [CelticPride21](https://wordpress.org/support/users/celticpride21/)
 * (@celticpride21)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/)
 * I was successfully able to load my scripts through the ‘functions.php’ file thanks
   to this post:
 * [http://wordpress.org/support/topic/someone-please-help-me-with-adding-a-jquery-script-to-wordpress](http://wordpress.org/support/topic/someone-please-help-me-with-adding-a-jquery-script-to-wordpress)
   
   _moderator note: a note has been added to that post that deregistering jQuery
   is never a good idea_
 * Unfortunately I’m not done just yet. I was planning on using this [script](http://slicknav.com/)
   for creating a responsive menu but noticed that it requires an initializer in
   order for it to load. The traditional method in their tutorial was to put it 
   at the bottom of your HTML file before the closing of your body tag. What would
   be the correct way in doing so for WP?

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348858)
 * The Enqueue function takes a final boolean parameter for this, true if you want
   it to be in the footer:
    [http://codex.wordpress.org/Function_Reference/wp_enqueue_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)
 *  Thread Starter [CelticPride21](https://wordpress.org/support/users/celticpride21/)
 * (@celticpride21)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348860)
 * Would you be able to write a small example for this? I’m new to jQuery/WP integration.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348861)
 * What is the code you’re using to enqueue the script at the moment?
 *  Thread Starter [CelticPride21](https://wordpress.org/support/users/celticpride21/)
 * (@celticpride21)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348862)
 * function my_init() {
    if (!is_admin()) { wp_deregister_script(‘jquery’); wp_register_script(‘
   jquery’, ‘[http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js&#8217](http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js&#8217);,
   false, ‘1.10.2’, true); wp_enqueue_script(‘jquery’);
 *  // My Custom Script
    wp_enqueue_script(‘scripts’, get_bloginfo(‘template_url’).‘/
   javascripts/scripts.js’, array(‘jquery’), ‘1.0’, true); } } add_action(‘init’,‘
   my_init’);
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348864)
 * Oh, you shouldn’t be deregistering jQuery. It can cause all sorts of problems
   in the future with the compatibility of your theme with the core WordPress application.
 * Regarding your enqueue function you are already putting the “scripts.js” file
   at the bottom of your page just before the “`</body>`” tag by setting the last
   bit (that I’ve highlighted in bold) as “true”:
 * wp_enqueue_script(‘scripts’, get_bloginfo(‘template_url’) . ‘/javascripts/scripts.
   js’, array(‘jquery’), ‘1.0’, **true**);
 *  Thread Starter [CelticPride21](https://wordpress.org/support/users/celticpride21/)
 * (@celticpride21)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348865)
 * 1) Should I remove the 3rd line, ‘wp_deregister_script(‘jquery’);’
 * 2) So in a sense by setting wp_enqueue_script I’m appending the code to the bottom
   of my page(s)? If so that makes so much more sense to me and thank you so much
   for clearing that up!
 * 3) My last question would be for a lot of these plugins they have their initializer
   and then a completely separate .js file. Should I just include the initializer
   in that .js file or is there something I’m still not understanding?
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348866)
 * 1) Replace all of your function with this:
 *     ```
       function my_init() {
           // My Custom Script
           wp_enqueue_script( 'scripts', get_bloginfo( 'template_url' ) . '/javascripts/scripts.js', array( 'jquery' ), '1.0', true );
       }
       add_action( 'wp_enqueue_scripts', 'my_init' );
       ```
   
 *  Thread Starter [CelticPride21](https://wordpress.org/support/users/celticpride21/)
 * (@celticpride21)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348876)
 * Worked out perfectly! Thank you. Any suggestions for #3?
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348905)
 * You can just put that inside your scripts.js file.

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

The topic ‘Initializing jQuery Scripts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 2 participants
 * Last reply from: [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/initializing-jquery-scripts/#post-4348905)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
