Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: How to move specific script to footer?

Discussion in 'Misc WordPress Requests' started by Daniel James, Feb 25, 2018.

  1. Daniel James

    Guest

    Reply To: How to move specific script to footer?, by Daniel James

    Take a look at the wp_deregister_script, wp_register_script and wp_enqueue_script function references. If a plugin is putting a script in the head and you want it in the footer, you need to deregister it first and then re-register it again and set the $in_footer value to true.

    Example:

    wp_deregister_script( 'my-script' );
    wp_register_script( 'my-script', 'https://example.com/my-script.js', array(), '1.2.3', true );
    wp_enqueue_script( 'my-script' );


    You can place the above code in your themes functions.php file and use the wp_enqueue_scripts action hook to include it.

    Reply To: How to move specific script to footer?
     
    #1

Share This Page

Monarch Social Sharing Plugin