This community-built FAQ covers the “jQuery Library” exercise from the lesson “jQuery Setup”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Introduction to jQuery
FAQs on the exercise jQuery Library
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
The diagram in this exercise places the
<script> tag below the closing
The old convention was to put scripts right before the
</body> tag to prevent the script from >blocking the rest of the HTML content. Now, however, the convention is to put the script tag in the
<head> element and to use the defer and async attributes.
Despite the above statements, multiple exercises from that course have the scripts tagged below the body. If you google search “script tag outside body” a lot of forum discussions pop up and the general consensus is that this is bad practice (although the reasons are not consistent). Some say that the code will not validate (I’m not sure what that means). Others say that the only reason documents written this way work is because browsers “tolerate” “broken html” and are able to correct mistakes like this.
For a while I have assumed Codeacademy exercises written this way were done so unintentionally. However, this diagram unambiguously shows the script below the body. What is the verdict?
yes I have the same question. Which of the three options is best to use, and why?
Same question for me, what is the best way to go nowadays?
I completely agree.
What can we do for someone (like an administrator) to clarify this?
Check out this post: When should I use the defer attribute on a <script> element in the <head> vs. using a <script> element at the end of the <body>?
It may help shed some light on the subject.
As far as placing the
<script></script> tag below the
</body> tag in the diagram referenced by the OP, that appears to be a mistake on the diagram. I submitted a bug report, and encourage others to do the same.