admin管理员组

文章数量:1310325

Given the advantages of connection reuse and multiplexing in HTTP2 (and SPDY) and the availability of gzip pression, is the effort of adding a minification and concatenation step into a build process justified?

Given the advantages of connection reuse and multiplexing in HTTP2 (and SPDY) and the availability of gzip pression, is the effort of adding a minification and concatenation step into a build process justified?

Share Improve this question asked Jan 30, 2014 at 9:12 EuanEuan 4192 silver badges12 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 5

According to Surma from the Chrome team, on H2 you can and in fact should stop bundling because it's useless and to allow more efficient browser caching:

https://www.youtube./watch?v=w--PU4HO9SM (time 1:10)

I think that minifying or obfuscating can still be desirable, depending on your needs.

Testing is the only true means of deciding to minify and/or concatenate when resources are being served via H2/SPDY.

The idea behind HTTP/2 (H2) is to serve small static resources on the stream (a single multiplexing TCP connection). Tests have shown that "most" sites benefit an increase of speed by not concatenating resources (and even not using a CDN). It all depends on the sizes of the resources being served on H2/SPDY. I have seen one site increase speed by 30%+ and others w/o change.

With that inmind, my suggestion is too test by minifing all resources and not concatenating them. I'd also test serving all mon resources (not using a CDN - and that as well depends where your clients are).

Resources:

  1. Akamai
  2. Columnist Patrick Stox
  3. HTTP/2 101 (Chrome Dev Summit 2015)

Yes you still need to minify and concatenate js and css files for the following reasons:

  • script minifying and SPDY pression are not the same. a good minifier knows to take advantage of local scope and replace verbose variable names with short repetitive names that are pression-friendly.

  • SPDY bines your requests so you don't have to stitch the scripts together. but not all browsers support SPDY

  • SPDY 2 and 3 are binary inpatible. When a browser supports 2 and the server advertises 3, the connection falls back to HTTP 1.1 over SSL; there's no SPDY benefits at all

  • loading 10 files through one request still incurs 10 fetches on the server side. bining the files reduces disk I/O.

Your question is parable to "can I care less about writing efficient code now that the machine can run faster?"

The answer is NO. Don't be lazy. Code properly.

本文标签: Should I minify and concatenate javascript and CSS when using HTTP2SPDYStack Overflow