CloudFlare Rocket Loader

2017年1月11日 | 分类: 【技术】

今天想拷贝一个万年历代码:http://www.vipcha.net/wnl/rili

发现这个页面的js都声明为:

<script type="text/rocketscript">

而不是:

<script type="text/javascript">

查了下,通过cloudflare.com 的js加速服务 的js 是这样写的。

参考:介绍CloudFlare功能及使用经验

除了CDN加速外,CloudFlare还使用各种方法对网站进行优化,包括压缩JS、CSS和HTML文件,让JS文件进行异步加载——Rocket Loader™,自动开启Gzip,充分使用现代浏览器的缓存功能,针对不同浏览器、不同终端进行进一步优化,同时CloudFlare也使用了高性能的nginx作为CDN的服务器,最大程度的加快网站访问速度,提高用户访问体验,最重要的是这些优化功能都是一键操作。使用CloudFlare之后Pagespeed的评分蹭到了95,载入网站时也更快了。

参考:http://stackoverflow.com/questions/32929015/cloudflares-rocket-script

CloudFlare’s Rocket Loader system is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload.

You can use Rocket Loader by adding the website you would like to enable Rocket Loader on to CloudFlare. CloudFlare automatically adds the code to every page on your website using DNS, no need for you to add it in yourself.

1. Sign up for CloudFlare at https://www.cloudflare.com/a/sign-up . Add your website to CloudFlare using CloudFlare’s easy to use wizard that should appear after you login.
2. Select your site from the list that should appear on your screen. A list may not appear as you have only one site in your account.
3. Select ‘Speed’ in the navigation bar: Navigation bar image
4. Scroll down to Rocket Loader and select the desired option, probably Automatic.
5. Give it a little while to propagate, stuff like this doesn’t happen instantly.

文档:https://support.cloudflare.com/hc/en-us/articles/200168056-What-does-Rocket-Loader-do-