There’s a reason, why one should use the proper hook, which – in this case – is wp_enqueue_scripts
.
Then always keep in mind, that some plugins might require a dependency/are dependent on another Javascript library like jQuery.
Now this example shows you how to enqueue your script
- With the right path/URI API function
- With jQuery as dependency
- With a on-demand-caching version number (file name changes, when file contents changes and prevents browser caching in case of an update).
- Loads in the footer to speed up page loading
That’s the right way of loading a script into a WordPress theme.
function wpse64374_register_slider_script()
{
wp_enqueue_script(
'easy-slider'
,get_stylesheet_directory_uri()."/js/easySlider1.5.js"
,array( 'jquery )
,filemtime( get_stylesheet_directory()."/js/easySlider1.5.js" )
,true
);
}
add_action( 'wp_enqueue_scripts', 'wpse64374_register_slider_script' );