Make Your Site Faster – Cloudflare’s CDNJS vs. Google Hosted Libraries – SHOCKING Results

I have used Google Hosted Libraries for as long as I can remember, and it’s what we use on Category5.TV to accelerate the javascript end of our site.  For all the javascript and CSS (plus images and so-on) we use that aren’t available through Google’s hosted solution, I use Amazon S3 and distribute it through Cloudflare to make it load quickly for our viewers.

I’ve been fast falling in love with Cloudflare’s CDNJS.

CDNJS boasts that it is in fact much faster than Google Hosted Libraries.

Neah… that can’t be true!  Google’s the “big dog”… Cloudflare is still relatively new.

RELATED VIDEO

So I took a look.  The first thing that shocked me was the absolute magnitude of how many javascript tools are available through CDNJS.  Gone is the need to (for example) load jQuery from Google Hosted Libraries but then have to download and deploy a copy of Fancybox 2 locally or on your own CDN.  CDNJS seems to have it all.  Or at least a great selection, plus the ability to add a library yourself via GitHub.

Sorry, what?  Yeah, baby.

So I thought, let’s run the world’s simplest test: how fast does wget receive the jQuery library on Linux?  It may not be a realistic benchmark in all cases, but it gives us a bit of a look at how quickly each service delivers the js.

Here are those simple (but amazing) results from my location in Ontario, Canada:

Google Hosted Libaries
robbie@robbie-debian:/tmp$ wget http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
–2013-03-22 13:50:47–  http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
Resolving ajax.googleapis.com… 74.125.133.95, 2607:f8b0:4001:c02::5f
Connecting to ajax.googleapis.com|74.125.133.95|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text/javascript]
Saving to: `jquery.min.js.1′ [ <=> ] 92,629      –.-K/s   in 0.1s

2013-03-22 13:50:47 (798 KB/s) – `jquery.min.js.1′ saved [92629]

CDNJS
robbie@robbie-debian:/tmp$ wget http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js
–2013-03-22 13:49:57–  http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js
Resolving cdnjs.cloudflare.com… 141.101.123.8, 190.93.243.8, 190.93.242.8, …
Connecting to cdnjs.cloudflare.com|141.101.123.8|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [application/x-javascript]
Saving to: `jquery.min.js’ [ <=> ]  92,629      –.-K/s   in 0.04s

2013-03-22 13:49:58 (2.21 MB/s) – `jquery.min.js’ saved [92629]

Note the filesize (92,629) is exactly the same; we’re dealing with the same version of jQuery here–identical files.  Also note that I’ve used a non-secure (http) connection for each.  The difference in speed is incredible.

Now, for a basic site, the fraction-of-a-second difference may not matter to you.  But for a big site like mine, this kind of difference could mean a full second off the load time–possibly more!  That’s unheard of for a simple copy-and-paste change in code.

Time to update Category5.TV.  What about your site?  Please comment below.

Update:  Garbee made a great point in our IRC room:  You’re only seeing results from my location.  Fair enough.  We want to make sure this isn’t just me that is experiencing such a massive difference.  Therefore, please run this exact test yourself, and post your results below in a comment.  I’m in Ontario, Canada.  Where are you?  Thanks!

First Day Results Extracted from Reader Comments:

  • Me:
    Ontario Canada – Google @ 798 KB/s, CDNJS @ 2.21 MB/s, CDNJS is 2.77x the speed of Google.
    Brea California – Google @ 2.27 MB/s, CDNJS @ 14.5 MB/s, CDNJS is 6.39x the speed of Google.
  • Garbee:
    Virginia USA – Google @ 429 KB/s, CDNJS @ 496 KB/s, CDNJS is 1.16x the speed of Google.
    New Jersey USA – Google @ 104 KB/s, CDNJS @ 2.60 MB/s, CDNJS is 25x the speed of Google.
  • Chris Neves:
    Montana USA – Google @ 123 KB/s, CDNJS @ 300 KB/s, CDNJS is 2.44x the speed of Google.
  • Alan Pope:
    Farnborough UK – Google @ 1.26 MB/s, CDNJS @ 1.16 MB/s, Google is 1.08x the speed of CDNJS.
    London England – Google @ 6.79 MB/s, CDNJS @ 4.72 MB/s, Google is 1.44x the speed of CDNJS.
  • steve5:
    Leeds UK – Google @ 153 KB/s, CDNJS @ 178 KB/s, CDNJS is 1.16x the speed of Google.
  • Bryce:
    Seattle Washington – Google @ 1.83 MB/s, CDNJS @ 659 KB/s, Google is 2.78x the speed of CDNJS.
  • Calvin:
    Massachusetts USA
    Test 1: Unsecure Connection
    – Google @ 810 KB/s, CDNJS @ 876 KB/s, CDNJS is 1.08x the speed of Google.
    Test 2: Secure Connection – Google @ 721 KB/s, CDNJS @ 1.08 MB/s, CDNJS is 1.5x the speed of Google.

CDNJS

5 1 vote
Article Rating
Subscribe
Notify of
guest
79 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Reb
Reb
6 years ago

Troyes, France

CDNJS: 548 KB/s
Google: 348 KB/s

rock
rock
7 years ago

Sao Paulo, Brazil

Google: 1.93 MB/s
CDNJS:  2.24 MB/s

Sander de Jong
7 years ago

I’ve ran 12 runs on both Google and CDNJS on HTTPS URLs for the latest jQuery, then excluded the slowest and fastest run for both, to get an average of 10 runs.

Result:
Google: 1603 kB/s
CDNJS: 1568 kB/s

Run from Groningen, the Netherlands

Ori a
Ori a
7 years ago

Israel, browser testing, jquery-2.2.4 minified:
jQueryCDN @ 80-106 ms
Google @ 97-104 ms
CDNJS @ 112-150 ms

Tough it really doesn’t matter – what matters most is amount of users already has a local cache of that file from elsewhere. Meaning that one should use the most used version, which I believe to be the jQueryCDN one.

 

Earnie Rhyker
7 years ago

Emmen, The Netherlands

Google: 4.19 MB/s

CDNJS: 2.75MB/s

Anonymous
Anonymous
8 years ago

Auckland, New Zealand

Google: 1.39 MB/s
CDNJS:  1.24 MB/s

Mike
Mike
8 years ago

CDNJS used to be a viable resource, and a great idea. Unfortunately, three years later, the maintainers have added so much cruft and useless layers of bureaucracy that makes it so difficult to add new libraries, that contributors are walking away rather than deal with the technical issues and arrogance of the maintainers. I’m sorry to say that the useful days of CDNJS are gone.

Peter Dave Hello
8 years ago
Reply to  Mike

Hi Mike,

CDNJS maintain here!

Sorry to make you feel bad about CDNJS project, I apologize if any thing we did or we are doing make you unhappy, we surely are not meant to be that arrogance as you think, yes it was hard to add new lib due the the fat repository for many months, that’s a very bad experience I think, but I would like to tell you a good news here, today, we are going to test the new feature – allow adding a new lib by a single package.json, now you don’t have to add the real files in the PR/commit any more, just add a package.json with a valid auto-update config, and we’ll handle the remaining things, which means you don’t need to clone the fat repository and work locally, just use the GitHub’s online editor, it won’t pain anymore.

In fact, CDNJS is a fully free and open source project, all of our contributors are not paid to do the works, we just want to make the world better, we even paid for the things we need to build CDNJS by ourselves, like the building servers, the heroku and digitalocean service, etc. Actually we all have our own jobs, as a main maintainer of this project, I’m still a full time master degree student, it’s impossible to do the works of CDNJS all the day, we need to make money to live, and all CDNJSers come from different places over the world, for example, I come from Taiwan, Thomas comes from Australia, and Ryan lives in the USA, the time we can work on CDNJS is very limited, especially the time we can work together, but there are many works and issues are waiting for us to solve, so the speed to figure out a problem may not be so fast, that’s the reality, but I promise we’ll do our best to solve all of the problems as fast as we can, sorry that it’s very hard to guarantee, but as you can see, even though that’s hard to send a PR, we are also be happy to accept issues, we even created a link like this – https://goo.gl/VBLhp9, to have a template for asking a library, and now we solved a problem about hard to add a lib. Today, CDNJS is still the web front-end CDN service that has the largest number of hosted libraries, we will keep going and doing better and better.

Best,
Peter.

YP
YP
9 years ago

Location Bulgaria
CDNJS …
<=>                                                                                                                                                      ] 92,629      –.-K/s   in 0.08s

2015-04-14 03:30:47 (1.15 MB/s) – “jquery.min.js” saved [92629]

GOOGLE …
<=>                                                                                                                                                      ] 92,629      –.-K/s   in 0.001s

2015-04-14 03:31:57 (69.8 MB/s) – “jquery.min.js” saved [92629]

Gabriel
Gabriel
9 years ago

Here are the results, from São Paulo, Brasil:

HTTP:

164KB/s on CDNJS

106 KB/s on Google CDN

HTTPS:

183KB/s on CDNJS

178 KB/s on Google CDN

 

The full log is below:

gabriel@Inspiron-1545:~$ wget http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
–2014-12-13 01:25:39– http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
Resolvendo cdnjs.cloudflare.com (cdnjs.cloudflare.com)… 198.41.215.185, 2400:cb00:2048:1::c629:d6b7, 2400:cb00:2048:1::c629:d6b8, …
Conectando-se a cdnjs.cloudflare.com (cdnjs.cloudflare.com)|198.41.215.185|:80… conectado.
A requisição HTTP foi enviada, aguardando resposta… 200 OK
Tamanho: não especificada [application/javascript]
Salvando em: “jquery.min.js.6”

[ <=> ] 84.280 164KB/s em 0,5s

2014-12-13 01:25:39 (164 KB/s) – “jquery.min.js.6” salvo [84280]

gabriel@Inspiron-1545:~$ wget https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
–2014-12-13 01:25:43– https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
Resolvendo cdnjs.cloudflare.com (cdnjs.cloudflare.com)… 198.41.215.185, 2400:cb00:2048:1::c629:d6b9
Conectando-se a cdnjs.cloudflare.com (cdnjs.cloudflare.com)|198.41.215.185|:443… conectado.
A requisição HTTP foi enviada, aguardando resposta… 200 OK
Tamanho: não especificada [application/javascript]
Salvando em: “jquery.min.js.7”

[ <=> ] 84.280 183KB/s em 0,4s

2014-12-13 01:25:43 (183 KB/s) – “jquery.min.js.7” salvo [84280]

gabriel@Inspiron-1545:~$ wget http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
–2014-12-13 01:26:21– http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
Resolvendo ajax.googleapis.com (ajax.googleapis.com)… 64.233.186.95, 2800:3f0:4003:c00::5f
Conectando-se a ajax.googleapis.com (ajax.googleapis.com)|64.233.186.95|:80… conectado.
A requisição HTTP foi enviada, aguardando resposta… 200 OK
Tamanho: não especificada [text/javascript]
Salvando em: “jquery.min.js.8”

[ <=> ] 84.245 106KB/s em 0,8s

2014-12-13 01:26:22 (106 KB/s) – “jquery.min.js.8” salvo [84245]

gabriel@Inspiron-1545:~$ wget https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
–2014-12-13 01:26:25– https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
Resolvendo ajax.googleapis.com (ajax.googleapis.com)… 64.233.186.95, 2800:3f0:4003:c00::5f
Conectando-se a ajax.googleapis.com (ajax.googleapis.com)|64.233.186.95|:443… conectado.
A requisição HTTP foi enviada, aguardando resposta… 200 OK
Tamanho: não especificada [text/javascript]
Salvando em: “jquery.min.js.9”

[ <=> ] 84.245 178KB/s em 0,5s

2014-12-13 01:26:26 (178 KB/s) – “jquery.min.js.9” salvo [84245]

Geoffrey Barth
9 years ago

yes your ajax.googleapis.com is in tiawan, some admins may block outside countries without know how this might effect web code…..

joysword
joysword
9 years ago

From Chicago.

———-short answer: cdnjs wins – 1.49MB vs 902KB————-
(venv)LongQuanJian:tmp joysword$ sudo !!
sudo wget http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
Password:
–2014-07-28 16:55:59–  http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js
Resolving cdnjs.cloudflare.com… 198.41.214.159, 198.41.215.159, 2400:cb00:2048:1::c629:d79f, …
Connecting to cdnjs.cloudflare.com|198.41.214.159|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 84280 (82K) [application/javascript]
Saving to: ‘jquery.min.js’

100%[==================================================================>] 84,280      –.-K/s   in 0.05s

2014-07-28 16:55:59 (1.49 MB/s) – ‘jquery.min.js’ saved [84280/84280]

(venv)LongQuanJian:tmp joysword$ sudo wget http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
–2014-07-28 16:56:27–  http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
Resolving ajax.googleapis.com… 74.125.193.95, 2607:f8b0:4001:c05::5f
Connecting to ajax.googleapis.com|74.125.193.95|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text/javascript]
Saving to: ‘jquery.min.js.1’

    [ <=>                                                               ] 84,245      –.-K/s   in 0.09s

2014-07-28 16:56:28 (902 KB/s) – ‘jquery.min.js.1’ saved [84245]

Ishan Das Sharma
9 years ago

I’m in India, with a horrible ISP, and a cheap connection. Here are my results

Google:

Test run 5 times. Time Average 0.5s @ 176 KB/s

CDNJs:

Test run 5 times. Time Average 0.52s @ 142 KB/s

 

From my Los Angeles Server:

Google:

Test Run 1 time:  0.09s @ 1015 KB/s

CDNJs:

Test Run 1 Time:  0.002s @ 42.2 MB/s

Note the HUGE Difference here

Henry
Henry
9 years ago

https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
2014-07-04 12:58:19 (901 KB/s)

https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js
2014-07-04 12:58:35 (1.68 MB/s)

Location: Hong Kong SAR, PRC

Fabian
10 years ago

From Bs As – Argentina

[root@srvapp ~]# wget http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js
–2014-04-04 10:01:15–  http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js
Resolving cdnjs.cloudflare.com… 198.41.213.183, 198.41.212.183, 198.41.213.184, …
Connecting to cdnjs.cloudflare.com|198.41.213.183|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [application/javascript]
Saving to: “jquery.min.js”

[   <=>                                 ] 92,629       209K/s   in 0.4s

2014-04-04 10:01:19 (209 KB/s) – “jquery.min.js” saved [92629]

[root@srvapp ~]# wget http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
–2014-04-04 10:04:05–  http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
Resolving ajax.googleapis.com… 74.125.21.95, 2607:f8b0:4002:c06::5f
Connecting to ajax.googleapis.com|74.125.21.95|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text/javascript]
Saving to: “jquery.min.js.1”

[   <=>                                 ] 92,629       196K/s   in 0.5s

2014-04-04 10:04:06 (196 KB/s) – “jquery.min.js.1” saved [92629]

Christofer Bodin
Christofer Bodin
10 years ago

Nice article! However here in Sweden the results aren’t that good for cdnjs. I’ve ran this 10 times for each CDN and i get almost the same result every time.

Location: Piteå, Norrbotten, Sweden.

Here’s a comparison:

bash-3.2$ wget -O- http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js > /dev/null
--2014-02-23 02:39:05--  http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
Resolving ajax.googleapis.com... 74.125.143.95, 2a00:1450:4010:c03::5f
Connecting to ajax.googleapis.com|74.125.143.95|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/javascript]
Saving to: ‘STDOUT’

    [ <=>                                   ] 96,381      --.-K/s   in 0.08s   

2014-02-23 02:39:06 (1.22 MB/s) - written to stdout [96381]

bash-3.2$ wget -O- http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js > /dev/null
--2014-02-23 02:38:04--  http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js
Resolving cdnjs.cloudflare.com... 198.41.213.162, 198.41.212.162, 2400:cb00:2048:1::c629:d4a2, ...
Connecting to cdnjs.cloudflare.com|198.41.213.162|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/javascript]
Saving to: ‘STDOUT’

    [ <=>                                   ] 96,381       615KB/s   in 0.2s   

2014-02-23 02:38:05 (615 KB/s) - written to stdout [96381]

 

Peter Dave Hello
8 years ago

Hi Christofer, is CDNJS still slow there? What about the result of google CDN? I’m not sure if I can help but I hope I can.