SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inclucing JS files at the bottom of the page

    I understand that JS files are best to be included at the bottom of the page now (someone noticed it increases speed). I've always put them within the <head>.

    If this is true, where exactly do I include the JS files?

    (1)
    Code:
    -- HERE --
    </body>
    </html>
    (2)
    Code:
    </body>
    -- HERE --
    </html>
    (3)
    Code:
    </body>
    </html>
    -- HERE --
    .. I notice that many sites still include the files in the <head>, including apple.com. Also, sitepoint.com has a load of JS going on at the top of the page. Why is this?

    Thanks.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by johnsmith153 View Post
    where exactly do I include the JS files?
    Only the first example that you give is legally allowed, which also happens to be the correct place at the end of the body.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •