Bundling .js files vs CDN

前端 未结 4 1278
有刺的猬
有刺的猬 2020-12-23 17:06

In order to improve performance of our web pages, we are recommended to use CDNs to serve .js files on our web pages. That makes sense.

Also, we are rec

4条回答
  •  北海茫月
    2020-12-23 17:57

    My answer: both. Bundle them and place them on a CDN.

    The downside of doing this? Depends. What does you build process look like? Can you easily automate the bundling and minification? Are you using Yahoo YUI or Google Closure or something else?

    Also, if there is a lot of GUI dependent jQuery there might be some time consuming friction due to constantly changing elements/effects/css.

    Testing is important too because due to possible minification quirks.

    Bottom line: 5 javascript files safely bundled into 1 file === 4 fewer requests.

    A page with just plain old Html and one external javascript reference === 2 requests to your server. However, a page with just plain old Html and one external javascript reference on a CDN === 1 request to your server.

    Currently we are using the Google Closure tools. The Google Closure Inspector helps with the following:

    Closure Compiler modifies your original JavaScript code and produces code that's smaller and more efficient than the original, but harder to read and debug. Closure Inspector helps by providing a source mapping feature, which identifies the line of original source code that corresponds to the compiled code.

提交回复
热议问题