php - Would it be better to include() resources (css,js) or to let the browser do another request? -


would faster include javascript file , outputting in html <script> or use src attribute , let browser make request?

simply outputting instead of letting browser make request mean less requests , possibly less server load, make faster? including files , outputting them doesn't let browser cache them.

if include it, every different page have overhead of downloading script again.

if externally link it, , send future expiry headers , use versioning cache buster (for changes), file downloaded once per required. on topic of performance, sure minify or pack production use javascript.

of course, relevant javascript. if few lines , not change, maybe could save 1 http request , place inline.

99% of time, however, in external file best practice.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -