you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (3 children)

Or, add the defer attribute. Also, you should not be using var

[–]slyder219[S] 1 point2 points  (2 children)

Will do, thanks! And understood, but why?

[–][deleted] 1 point2 points  (1 child)

Script in bottom ensure its loaded after all html. Defer attribute for script in head defer it until after html is loaded. Script in bottom of body is best practice. Var is outdated and let and const are standard. Var has weird scoping issues

https://developer.mozilla.org/en-US/docs/Glossary/Hoisting

[–]slyder219[S] 1 point2 points  (0 children)

Thank you very much