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 );
?>

Parameter

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

Default: None

$src
(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

$deps
(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

$ver
(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:

 <?php
function my_init_method1() {
wp_enqueue_script('jquery');
}

add_action('init', my_init_method1);
?>

Load the scriptaculous script:

 <?php
function my_init_method() {
wp_enqueue_script('scriptaculous');
}

add_action('init', my_init_method);
?>

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

<?php
wp_enqueue_script('handle', 'src', 'dependencies');
?>

<?php wp_enqueue_script('jquery-name', 'http://yoursite.com/wp-content/themes/your_theme/jquery/jquery-ui-tabs.js', 'jquery'); ?>

/*
Parameters:
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.