Mobile app version of vmapp.org
Login or Join
Samaraweera270

: Local files vs. CDN If website load time is a concern which is generally better to use when referencing a JavaScript or CSS file? Would using a CDN be better or would that just add more

@Samaraweera270

Posted in: #Cdn #Optimization

If website load time is a concern which is generally better to use when referencing a JavaScript or CSS file? Would using a CDN be better or would that just add more HTTP requests?

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Samaraweera270

4 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

Using a CDN can be both a burden and a benefit to a website, all depending on how it has been implemented.

Positive Points


Static content stored closer to the end user (faster loading times)
Additional sub-domains (cdn1.domain.com, cdn2.domain.com, etc), this assists with the inherit limit in browsers limiting file downloads to two simultaneous files from the same fully qualified domain name at any one time. In other words using this example you would access HTML from domain.com and all the while be downloading 2 files from cdn1.domain.com, 2 files from cdn2.domain.com, and 2 files from cdn3.domain.com with all three cdn domains accessing the one cdn service and source.

10% popularity Vote Up Vote Down


 

@Connie744

Use a CDN if you need a CDN. If your user is global and spread over a large area, or you have a lot of such content that you don't want to store on your own server, that is when a CDN is useful. Globally, it can speed up access to your content if the server is closer to the user. If you have many GB or Terabytes of static data and a heavy load for access to that content, a CDN can help with that.

However, small, local sites or lightly loaded sites rarely need such things and a CDN can only add one more complication to your set up, operation and workflow, such as caching problems.

Too often I see people use a CDN cause they read they should be using one and no other reason.

10% popularity Vote Up Vote Down


 

@Sent6035632

Using a CDN vs traditional web hosting for delivering your static files such as CSS, JS, and images is commonly preferred. This is because once your files are cached on the CDN's edge servers, your site visitors will be delivered static content from the closest point of presence (PoP) instead of the origin server.

In the majority of cases, this shortens the distance between the client and the server and thus helps improve loading times without adding any additional HTTP requests. This also helps in other areas such as increasing redundancy, taking a load off the origin, etc.

10% popularity Vote Up Vote Down


 

@Cody1181609

The CDN should be used for all static files (.css/.js/images).

Sometimes however javascript or css files can have dynamic aspect to them such as that it would include a unique user string or something of that sort. In this situation the CDN server would have to contact the origin server on every request which would defeat the purpose.

If your CSS and Javascript is static for all users then using a CDN is the right way to go. This would not cause any extra HTTP requests because it would only load the css and js files from the CDN instead of your own webserver (unless you are using inline code). So instead of a users browser loading these requests from your server they would be loaded via the CDN, there is no additional requests you are just changing where to send these requests (again as long as you are currently not using inline code).

Other benefits from using a CDN would be that the CDN server would most likely be located closer to your end users then your origin which will benefit loading times. The CDN servers are also likely setup to serve static content much faster then your origin server by specifically catering the web server for static content.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme