Serve libraries with CDN or own server?

4
For performance purposes it is more performative to use a CDN (which provides the full and primary version of the library) or distribute versions of Custom Libraries (ex: jQuery UI which provides only the accordion effect). Is it possible for my site to also use jQuery UI downloaded by another site even though it is different (complete and my costumed having only the necessary function)? Is there any other crucial factor?

    
asked by anonymous 28.05.2015 / 15:57

2 answers

5

The main function of a CDN for a developer is not to worry about network traffic and to be able to guarantee visitors the availability of files at all times. For the user is to obtain from a second domain (parallel loading) the files, from a place that would probably be closer physically decreasing the latency (connection time, DNS resolution and download).

If your visitors are geographically close to you, or are unique to a locality (country, country or continent), there is NO MUCH need for a CDN, as users will not make that much difference. In this case, I recommend that you create a subdomain or even another domain (that's your strategy) to serve those files. So you can serve in parallel and a cookieless domain.

Ideally, you should make your pages to make the least amount of requests (both for the same domain and for many: CDN, subdomains, etc.), so you increase the speed of page loading.

Try to merge into just one .css or .js file (you can build on separate files, but when posting put it all together, or use tools that do this) all code that will be used by a particular area of your site . Compacte (remove unneeded spaces, indentations, comments, use GZIP compression), and cache these files (set the files to be in the user's cache for as long as possible, and if you update the data in the files then change the URL that the user search, forcing a new download, updated).

If you are going to provide customization and are using scripting libraries, do not provide the library for a CDN and its customization to the part of your server (or your own CDN). Put it all together into one and make everything available to your users. Initially you will increase your server traffic a bit, however you will decrease the requests from the users and will have control over the cache of these files completely.

    
28.05.2015 / 16:29
4

Each strategy has its pros and cons ...

CDN: The great advantage is that most users who fall into your site will have a version of the library in the cache. This reduces the time to download resources and bandwidth consumption of your site. CDNs also try to distribute libraries from a server closer to the user, so if they need to download a library, it will do so with less latency.

Custom Version : The first time your users access the site (and in later iterations if they no longer have the cached library) they will need to download the library from your server. The latency of a distant user may be high, and this will consume your upload bandwidth. On the other hand, you can select only what you need from each library (which can reduce the download size as well as the rendering time).

  

Is it possible for my website to also use the jQuery UI downloaded by another website, even though it is different (complete and my custumizada having only the necessary function)?

I do not know if I understand the right question, but if you developed your site in a customized version (with only part of the components), you can switch to the most complete version hosted on a CDN without problems. The more popular the CDN, the less chance a user has of downloading the library.

    
28.05.2015 / 16:17