Most of the wordpress programmer don’t know that most of the javascripts libraries are already loaded in to the wordpress, So if you want to use them in your theme you only have to call them using the wp_enqueue_script

When you want to include javacript libraries in your theme you have to call the wp_enqueue_script() function using simple parameters.

<?php wp_enqueue_script( $handle, $src, $deps, $ver );


(string) (required) Name of the script. Lowercase string.

Default: None

(string) (optional) Path to the script from the root directory of WordPress. Example: “/wp-includes/js/scriptaculous/scriptaculous.js”. This parameter is only required when WordPress does not already know about this script.

Default: None

(array) (optional) Array of handles of any script that this script depends on; scripts that must be loaded before this script. false if there are no dependencies. This parameter is only required when WordPress does not already know about this script.

Default: None

(string) (optional) String specifying the script version number, if it has one. Defaults to false. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the script.

Default: None

So as all the javascripts libraries like Jquery,Scriptaculous,Tiny MCE,ThickBox are already included in wordpress, you don’t have to upload and include in your wordpress theme again, so you have to just include them in the wordpress theme using the wp_enqueue_script().

So when you want to include jquery in your theme you have to call

Load the jquery script:

function my_init_method1() {

add_action('init', my_init_method1);

Load the scriptaculous script:

function my_init_method() {

add_action('init', my_init_method);

This function can be used to include your own javascript files using

wp_enqueue_script('handle', 'src', 'dependencies');

<?php wp_enqueue_script('jquery-name', '', 'jquery'); ?>

handle= Is a unique name that you want to give to your script.
src= Is the script url
dependencies= Optional parameter that allows you to specify dependencies. Like which script must be loaded before this script. In some jquery plugins you have to load other plugins first. In that case this function is very useful
Example of dependencies

Note: This function will not work if it is called from a wp_head action, as the <script> tags are output before wp_head runs. Instead, call wp_enqueue_script from an init action function (to load it in all pages), template_redirect (to load it in public pages only), or admin_print_scripts (for admin pages only). Do not use wp_print_scripts (see here for an explanation).

The function will also ensure that the same script will not be loaded again, Which means if you include jQuery in your theme, and you install a plugin that tries to load jQuery, it will only be loaded only once.