• I tried to move the jquery and other js files from header to footer to improve SEO scores with the following code but it didn’t work.

    function move_jquery_to_footer() {
       if (!is_admin()) {
          wp_deregister_script('jquery');
          wp_register_script('jquery','https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', false, null,true);
          wp_enqueue_script('jquery');
       }
    }
    add_action ('wp_enqueue_scripts', 'move_jquery_to_footer');
    

    The code works for other themes, but for some reason it doesn’t work for your theme. Any reason why?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Raam Dev

    (@raamdev)

    The Independent Publisher theme does not explicitly enqueue jQuery anywhere; it just includes it as a dependency when enqueuing other JS files (see these lines in functions.php).

    Thread Starter hcheung

    (@hcheung)

    Thanks for the reply. Yes, there seems to be quite standard on the wp_enqueue_scripts at the functions.php. However, I do noticed that most of the js files get moved to the footer, except for the jquery and the enhanced-comment-form.js. I also download the theme Publisher which is where Independent Publisher inspired from, and it does not have the problem because it does not have the enhanced-comment-form. So I think this has to do with how the enhanced-comment-form get to enqueue into the <head>.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Moving js files to footer’ is closed to new replies.