0

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?

8
  • Is there <?php wp_footer(); ?> in your theme? Commented Mar 22, 2017 at 12:24
  • yes @RohitKishore Commented Mar 22, 2017 at 12:25
  • @RohitKishore what is the difference between the code?? Commented Mar 22, 2017 at 12:32
  • The arguments in the last Commented Mar 22, 2017 at 12:39
  • wordpress.stackexchange.com/questions/37960/… Commented Mar 22, 2017 at 12:52

1 Answer 1

0

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.