1
iHackCode
Where do you include your JS?

Hi All,

Where do you include your Javascript. Do you include it in the HEAD or right before the closing BODY tag?

or does it depend.

2
vamptrix
Re: Where do you include your JS?
  • 2015/2/25 23:33

  • vamptrix

  • Theme Designer

  • Posts: 424

  • Since: 2008/5/3 1


I prefer to use it in the header, but footer is better for loading times.
All in all, I think it comes down to personal choice.

3
iHackCode
Re: Where do you include your JS?

Ah okay

4
zyspec
Re: Where do you include your JS?
  • 2015/2/26 4:33

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


There are instances where you get race conditions and loading your js in the footer does 'help' (although not prevent) some of these conditions. What you typically see in these instances is that the js tries to execute before the html element has been loaded giving you an undefined error message.

There are better ways to prevent this, but more difficult to implement.

Login

Who's Online

284 user(s) are online (143 user(s) are browsing Support Forums)


Members: 0


Guests: 284


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits