Why inline JavaScript is bad?

前端 未结 9 849
梦谈多话
梦谈多话 2020-11-29 08:13

It is always recommended to avoid inline Javascript codes by putting all codes in a JS file, which is included in all pages. I wonder, if this does not cause pe

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 08:55

    Inline styles/script gets muddled with html content and can get hard to differentiate. One of the the keys to having maintainable code in web development is writing code that is easily readable by someone who didn't write it. Mixing script tags into your html can make it very hard to find a function that is affecting the rest of you code. Putting Javascript in .js files and Styles in CSS files makes code cleaner more readable.

提交回复
热议问题