Search code examples
javascripthtmlcssperformancecdn

Could CDN be faster way to load resources?


I was setting up the admin panel for a blog today, and I decided just to use the CDN bootstrap link rather than keeping the files local on the server since this was just some initial testing. I figured that I would add the files to the server later in order to speed it up, but that's when I had a thought.

This particular server is a Bluehost shared server and is inexplicably slow. Could it actually be faster if I used the CDN? And would it be noticeable?

I know StackOverflow likes questions to be specific, so let's use Bootstrap's CDN in this particular scenario since it is a popular framework.


Solution

  • Could it actually be faster if I used the CDN?

    Yes. CDNs are a good option not only because they are usually very fast servers, but also because when you use a popular CDN, the sources you need (e.g. boostrap, jQuery) may have already been downloaded by the user at another site and, as such, will hit the browser's cache - and then load as fast as it possibly could.

    And would it be noticeable?

    This depends on how slow the current server is in relation to the CDN.

    Google DevTools have a useful tool to this. They have a whole section dedicated to that: Get Started with Analyzing Network Performance in Chrome DevTools. It includes guided to tools that assist you in emulating connections and devices, analyzing requests (find out which scripts are taking longer to load or which stylesheets are affecting rendering), and more.

    x
    (source: google.com)

    In the example above you can see how much time a resource actually took to download. That screen is available at Chrome (Command+Option+I [Mac] or Control+Shift+I [Windows, Linux]).