0

Would async script loaders like LABjs or $script.js prove beneficial, neutral, or negative if already using a CDN supporting SPDY?

  1. I'm going to use a full-site CDN with SPDY, for example Cloudflare
  2. I've read Script-injected "async scripts" considered harmful but thanks to jQuery dependencies I need to control execution order.
  3. I want to keep dependencies as unbundled as possible

i.e. I've got a series of JS scripts where <script src= would work fine and <script async src= would not. I don't want sync because it would be blocking. And defer is too flaky to consider.

Given the above, I would use a script loader without second thought if it weren't for the uncertainty of SPDY. I probably just need to know whether the approach used by these scripts still gets the same SPDY benefits (pipelining, compression, etc) as "regular" approaches?

Another way of framing the question is: what would be the impact of switching from synchronous script loading with SPDY CDN to using async script loaders with SPDY CDN?

4

1 回答 1

0

使用 Cloudflare 作为 SPDY 代理时,我遇到了非常糟糕的性能问题,我的基准测试从 SPDY 的 1.5 秒到大约 4 秒(慢了 266%)。您应该测试自己,并且通过直接连接到您的服务器,您应该会看到更快的结果。

CDN 会减慢您的速度,因为 SPDY 允许从一个套接字连接中提取所有资源,而 CDN (https) 将需要多次 TLS 握手和往返连接,这可能会减慢您的站点速度。

此测试显示通过 SPDY 加载了大约 350 个资源,您不会使用 CDN 获得这些结果:http: //httpvshttps.com/

这是一篇有趣的文章:

https://thethemefoundry.com/blog/why-we-dont-use-a-cdn-spdy-ssl/

于 2014-12-01T08:39:20.880 回答