Streaming jquery(JS files) from a CDN (Google)

前端 未结 5 1261
说谎
说谎 2020-12-19 13:15

This one is a case of not doing your homework.:-)

Apart from dynamic loading advantage, does it make sense to include a JavaScript library(jQuery in my case ) from

5条回答
  •  遥遥无期
    2020-12-19 13:31

    Consider that a jQuery script downloaded from the google CDN might well already be cached on a visitor's browser, since it has consistent headers and cache control no matter where it is downloaded from. Hence, on average most users will only have to download your site-specific javascript scripts. Also, CDN generally have faster response times than single servers, since they respond from a server nearest to your location.

    There is no cut and dry answer to your question, as both approaches offer good performance on modern connections. You should profile your system under duress and see what solution offers the best results (and if such optimization is even needed).

提交回复
热议问题