Why bundle optimizations are no longer a concern in HTTP/2

后端 未结 4 656
温柔的废话
温柔的废话 2020-12-04 19:52

I read in bundling parts of systemjs documentation that bundling optimizations no longer needed in HTTP/2:

Over HTTP/2 this approach may be preferable

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 20:18

    Bundling is doing a lot in a modern JavaScript build. HTTP/2 only addresses the optimisation of minimising the amount of requests between the client and server by making the cost of additional requests much cheaper than with HTTP/1

    But bundling today is not only about minimising the count of requests between the client and the server. Two other relevant aspects are:

    • Tree Shaking: Modern bundlers like WebPack and Rollup can eliminate unused code (even from 3rd party libraries).
    • Compression: Bigger JavaScript bundles can be better compressed (gzip, zopfli ...)

    Also HTTP/2 server push can waste bandwidth by pushing resources that the browser does not need, because he still has them in the cache.

    Two good posts about the topic are:

    • http://engineering.khanacademy.org/posts/js-packaging-http2.htm
    • https://www.contentful.com/blog/2017/04/04/es6-modules-support-lands-in-browsers-is-it-time-to-rethink-bundling/

    Both those posts come to the conclusion that "build processes are here to stay".

提交回复
热议问题