304 latency versus embedded javascript

On the Internet, there seems to be a general conclusion that external js files are better.

The main reasons are caching, maintenance, and debugging.

However, there doesn't seem to be much discussion of the overhead of 304 HTTP requests. I went to yahoo.com and noticed that 304 for each javascript file has an overhead of about 30 ms per file (mainly related to connecting and responding).

I have separate javascript files (solution to a maintenance problem). I don't really need debugging (automated tests are very useful).

I am considering whether to pack and embed them in a single script tag on top of an html document. I know there is a point at which this makes no sense (when my javascript is very large), and I have to check this out.

I'm just wondering if anyone has done any tests on this subject, what results did they get?

+3
source share
4 answers

I also do not have benchmarks, it also depends on the connection delay. but subjectively, I never felt this delay.

I would recommend to separate the dynamic content (html that you rendered on the server) and static content (css, js). first of all, the payload of your html gets much less (you save server rendering time + payload lower), and, in addition, this is a clear separation and is better served from the point of view of codes.

GET (, Modified-Since Etags), Expires. http-.

+3

, . , 30 , HTML- JS (, javascript -, JS ).

, ? , , , JS , , , ( , , F5 . ).

- , , JavaScript, XML- XHTML+. JS , .

JS , , , JavaScript HTML.

+1

, @getify @zoompf, .

<script>? .js? CSS - ?

. http://mathiasbynens.be/notes/inline-vs-separate-file .

+1

, 304 .

cache-control: public, max-age = 3600

, . , .

-: max-age = 3600

, , , .

js , . , - http://code.google.com/p/talifun-web/wiki/CrusherModule js etag, md5 . , , .

+1

Source: https://habr.com/ru/post/1748220/


All Articles