Reduce HTTP requests or not?

前端 未结 7 1984
野性不改
野性不改 2021-02-01 05:57

A theoretical question:
We all know about the pro\'s of minifying and combining javascript files in order to reduce HTTP requests to speed up a website. But when popular jav

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 06:33

    I think it depends on you site:

    • If you site consists mainly of pages of the same type which need the same scripts I would go for A)
    • If you have a lot of scripts that differ from each sub site of you site I would go for B). Combine the most used scripts together in one script. If you have large scripts that are not used on every page, make a separate script for it.

    The best way to really know what to do is to test which combination of techniques saves you the the most traffic / connections.

    P.S.: I personally do not like the idea to let other people serve files for my webpage, because what will happen if the CDN fails, but your server stays alive? If this is not a problem for you, try to server all libraries you use from a reliable CDN.

提交回复
热议问题