[JS and the DOM > JQuery(4/16)] Suggestion for the instruction: Mention <head> instead of </body>


Link: https://www.codecademy.com/courses/learn-javascript/lessons/javascript-dom/exercises/jquery

Before I start, I’d like to say that I have already created a simple beginner website using JQuery so I guess I’m pretty familiar with the basics. But I’m taking this course anyway and I’m doing it in a way as if I have zero knowledge about the subject.

My concern is in the first instruction that says “[…] Before the closing </body> tag, right above your current <script> tag, include this code: […]”. Confusing instruction or is it just me lol

What I understood from the instruction is that a </body> tag exists above a <script> tag. The only script tag in the html file is in the <head> and not in the <body>. Now, I looked for the </body> in <head> even though I know that body must be outside the head haha

So in my first try, I placed the script tag for the JQuery file just a line above the </body> and of course the code gave an error. I corrected it and placed the script tag in the head part.

I reread the instruction and for some reason it made sense haha. I wonder if my confusion is just because English is not my native language, or just pure poor comprehension… There’s something wrong with my thinking process haha

tl;dr: I think the instruction should mention that the <script> is found inside the <head> instead of saying before the </body> tag.

ps sorry for posting about my misinterpreting an instruction but im posting it anyway haha and thanks for baring with my english xD


Loading the script at the end of the body element is perfectly fine, and in many cases recommended so as to not interfere with loading page elements. HTML downloads first and populates the DOM, CSS comes down next and gets parsed into all the DOM nodes according to selectors, this helps the page get drawn, and finally the script for jQuery is pulled down which installs the jQuery class followed by the custom script which begins execution as soon as it loads. All very normal and orderly.


This topic was automatically closed after 7 days. New replies are no longer allowed.