[resolved] Should I put all javascript links in the footer? (3 posts)

  1. neilmac
    Posted 7 years ago #

    I hear - eg from Google analytics - that you should put your javascript links above the closing body tag to speed up your site but most WP sites I visit have them in the head.
    Is there any reason why I should not move my js links into my footer?
    Is this better practice?
    Any red flags?

  2. alanft
    Posted 7 years ago #

    if the js doesn't make a difference to the way the page should look when first loaded, then footer is fine - it defers the loading of the code until the page is rendered on most browsers.

    JS linking in the HEAD has to be downloaded before a page starts to render on most browsers, so it slows down the site's apparent responsiveness


  3. neilmac
    Posted 7 years ago #

    Thanks very much Alan.
    I have now decided I don't need that particular bit of javascript in any other pages apart from the home.php
    So rather than place it right in the footer I have moved it to the bottom of home.php
    That's not ideal for the home page - though it's better - but it does mean the other pages load much faster as they don't even call the js from the footer.

Topic Closed

This topic has been closed to new replies.

About this Topic