-3

My question is simple is it better to have css and js in-line on every single file of html or have it so every html page pulls from an external css/js file... Thanks in advance.

  • 2
    [External CSS vs inline style performance difference?](https://stackoverflow.com/questions/8284365/external-css-vs-inline-style-performance-difference) – Nir Berko Jul 14 '18 at 11:40
  • It really depends. If you were going to only need a style once or script once then yes, you could go with inline. If you are going to reuse a style or script then it is best to put them in their own file. With styling, I find that this is almost always the way to go. It really depends on what you need to accomplish though. – Devon Kiss Jul 14 '18 at 11:40
  • Yes that was my problem i will be using it several times so i imagened it would be better to have it in a seperated file – Gonçalo Midões Jul 14 '18 at 11:59

2 Answers2

3

External CSS is always a better option. Here are the advantages:

  • Less Duplication
  • Reuse of CSS using classes
  • Maintainable code
  • Easy to understand and increased readability
  • Simplified HTML template.
Harshal Yeole
  • 4,812
  • 1
  • 21
  • 43
-1

You should keep your js and css files external. Apart from readability, with that way you increase the performance of your site(or web app) as it can easily be cached by the browser. You can read some more detailed answers here:

internal js or external file

inline css or external file

Cache
  • 471
  • 2
  • 5
  • 14