Is it bad practice to embed JavaScript into the body of HTML?

前端 未结 17 2499
梦谈多话
梦谈多话 2020-12-13 01:44

A team that I am working on has gotten into the habit of using

17条回答
  •  星月不相逢
    2020-12-13 02:09

    However, it's also good in that you know the JavaScript code needed for a section of HTML is going to be there for it. Rather than having to assert and build up some inclusion at the top of the file.

    So, rather than "if you're going to use this HTML, make sure you import xyz.js" you can just include the HTML and be done with it.

    So, it's not necessarily horrible evil. Perhaps not spectacularly awesome, but not utterly terrible either. It kind of depends on the intent.

提交回复
热议问题