« Zurück

AlloyUI and the importance of CDN

Company Blogs 4. März 2013 Von Zeno Rocha Staff

Some weeks ago we announced the preview release of AlloyUI 2.0. One of the cool things about it is that now we have a pretty new CDN (Content Delivery Network). So instead of downloading AlloyUI to use in your local environment, you just to need copy and paste this line of code and start using it.

	<script src="http://cdn.alloyui.com/2.0.0pr2/aui/aui-min.js"></script>

But it was only available for AlloyUI 2.0, which is not integrated with Liferay yet, then Liferay community wouldn't benefit from it.

That's why today we have some news to share, all versions of AlloyUI are now available on CDN to use in production or to download as a zip file \o/

PS: Check this table if you don't know which version is being used by Liferay.


Why it's so important to use a file hosted on a CDN?

Basically for performance improvements, we'll dig into some of them.


Decrease latency

Let's say you are in China and your server is in Los Angeles. When you load a file the browsers sends a HTTP request that will go across the globe until reach your server and, as you can see, it takes time.

However if this file is hosted on a CDN it will be distributed across many different servers in the world. So when you make a request, it will look for the nearest server, which decreases latency time a lot.

Wikipedia: (Left) Traditional scheme of distribution - (Right) CDN scheme of distribution


More parallel downloads

Browsers can't handle too many parallel downloads per domain.

That's why hosting files in different domains is a good performance tip.



Let's say you visited a website that uses AlloyUI hosted on CDN, as soon as you load it your browser will automatically cache it in your machine. Then if you visit another website that uses AlloyUI too, you don't need to download all those files again because you already have cached them.


What's the real benefit?

Let's try those performance improvements in real life. My experiment will load the exact same file using a CDN and don't using it.

Didn't use CDN:

When you load this file, that is not hosted on a CDN with a 10mb internet connection, you take 1.27 seconds with 404ms of latency.

Use CDN:

But when you load this file, that is now hosted on a CDN with the same internet connection, you take 314ms with 155ms of latency.

That's a 75% decrease and this is only one file!

Now imagine a lot of modules and its dependencies being loaded, it will cause a significant difference.



And that's all folks! If you have any questions please comment below :)

Antworten im Thread Autor Datum
That was a wise choice, Zeno! Let's make it not... Cleydyr de Albuquerque 4. März 2013 11:59
Exactly Cleydyr! Zeno Rocha 4. März 2013 15:15
Once AUI2 is loaded, will it have a confliction... Neil Jin 5. März 2013 06:34
Yeah, it will probably cause a conflict. Soon... Zeno Rocha 6. März 2013 05:12
Has anyone here tried loading 2.0 via CDN over... Joseph Cook 10. April 2013 08:31
It will probably break almost everything. We're... Zeno Rocha 11. April 2013 22:13
Hi Zeno, how about the https CDN when that is... Sampsa Sohlman 9. März 2013 14:12
Hey Sampsa, We're discussing that:... Zeno Rocha 18. März 2013 06:37
Excellent Job team! Shagul Khajamohideen 12. März 2013 06:18

That was a wise choice, Zeno! Let's make it not only simple and sexy, but also lightning fast to load wherever it is used.
Gepostet am 04.03.13 11:59.
Once AUI2 is loaded, will it have a confliction with preloaded AUI library in LiIferay?
Gepostet am 05.03.13 06:34.
Yeah, it will probably cause a conflict. Soon we're going to migrate Liferay to AUI2 emoticon
Gepostet am 06.03.13 05:12 als Antwort auf Zhao Jin.
Hi Zeno, how about the https CDN when that is coming?
Gepostet am 09.03.13 14:12.
Hey Sampsa,

We're discussing that: https://github.com/liferay/alloy-ui/issues/25
Gepostet am 18.03.13 06:37 als Antwort auf Sampsa Sohlman.
Has anyone here tried loading 2.0 via CDN over say a 6.1.1 install? If so, how bad were the conflicts?
Gepostet am 10.04.13 08:31 als Antwort auf Zeno Rocha.
It will probably break almost everything. We're working on it Joseph, soon AlloyUI 2.0 will be available under 6.2
Gepostet am 11.04.13 22:13 als Antwort auf Joseph Cook.