i have below code which enqueues javascript.

wp_enqueue_script( 'jquery.flexslider', get_template_directory_uri().'/library/js/flex-slider/jquery.flexslider-min.js',  array( 'jquery' ));

Above code is not in functions.php. it is in library/siteframework.php

What i understand is in order to any javascript work in wp, it got to be registered or enqueued.

I want to enqueue the javascript and don't want to call it in head.

With above code in place, html source automatically calls script in head as below...

<script type='text/javascript' src='http://domain.com/wp-content/themes/WHMFront/library/js/flex-slider/jquery.flexslider-min.js'>

if i remove enqueueing code then script call disappears from head.

I tried below code in functions.php. did not work.

function wpdocs_theme_name_scripts() {
wp_register_script( 'jquery.flexslider', get_template_directory_uri() . '/library/js/flex-slider/jquery.flexslider-min.js', array(), '1.0.0', true );

wp_enqueue_script('jquery.flexslider'); } add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );

How to register or enqueue script and stop it being called in head?


1 Answer 1


In siteframework.php file change code to:

 wp_enqueue_script( 'jquery.flexslider', get_template_directory_uri().'/library/js/flex-slider/jquery.flexslider-min.js',  array( 'jquery' ), '1.0.0', true); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.