1.

When to use scripts in the head and when to use scripts in the body?

Answer»

If the scripts contain some EVENT-triggered FUNCTIONS or jquery library then we should use them in the head SECTION. If the script writes the content on the page or is not inside a function then it should be placed inside the body section at the BOTTOM. In short, follow below three points:

  1. Place library scripts or event scripts in the head section.
  2. Place normal scripts that do not write anything on the page, in the head section until there is any performance issue.
  3. Place scripts that render something on the web page at the bottom of the body section.


Discussion

No Comment Found