JavaScript AJAX Basics (retiring) jQuery and AJAX Posting Data with jQuery

Aleksandrs Karevs
PRO
Aleksandrs Karevs
Pro Student 11,178 Points

Isn't it a bad practice to insert scripts directly into the HTML?

I've read in Jon Duckett's book – "Javascript & jQuery – interactive front-end development" that it is generally considered a bad practice to insert your scripts directly into the HTML document. Instead, you are better of inserting it into a separate .js file and than linking back to it from within HTML.

What are your thoughts on this subject?

4 Answers

Josselin Cuette
Josselin Cuette
2,672 Points

You are right, it is bad practice, but I think that this kind of course intends to simplify things for the sake of demonstration. :)

Great course! But I agree, best practices should be taught alongside the course content. Newer programmers may assume this is ok when it isn't.

Jeremy Castanza
Jeremy Castanza
12,075 Points

Good observation. Typically, there's a pattern to follow and best practices dictate separating structure, design, and behavior in a web page.

  • HTML Files - Used for structure
  • CSS Files - Used for design/layout
  • Javascript Files - Used for behavior/manipulation