#1
  1. A Change of Season
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,246
    Rep Power
    220

    Is it safe to use CDN?


    Hello;

    Whats the downside of using these directly instead of loading them to my sites directory?

    https://cdnjs.com/libraries/zeroclipboard

    Or

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

    Much love
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,435
    Rep Power
    9645
    If they're providing a CDN for free, public use and then telling people to use them then there's no downside.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2015
    Location
    Canada
    Posts
    24
    Rep Power
    0
    (And the upside is they should increase the speed your page loads as those assets are coming from different servers.)
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Location
    Jakarta, Indonesia.
    Posts
    279
    Rep Power
    37
    I'll make a table:
    MY SERVER STATUS: CDN STATUS: WHAT MY VISITORS SEE:
    up up fully functional page
    up down half functioning page
    down up don't see page at all
    down down don't see page at all

    So CDN would be good when library puts a pretty big load on my server,
    or perhaps when I have reached my server capacity limit.

    But there's no JS / CSS libraries > than 100K (averagely, size of one image for web), is there?
  8. #5
  9. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,435
    Rep Power
    9645
    A CDN is very, very unlikely to be down - after all, uptime is one of the big selling points of a CDN - so really the possibilities are having a fully functional page or your site is down.
    And of course the site should never be down (if it is then the CDN is the least of your concerns) so you're just left with the site being up and fully functional, and you get the benefits of having CDNed assets without the downside of having to manage and pay for the CDN yourself.

    A few libraries:
    - jQuery 1.11.3: minimized 38KB, full 102KB
    - jQuery UI 1.11.4: minimized 78KB, full 141KB
    - YUI 3.18.1 (dead): minimized 27KB, full 81KB
    - Prototype 1.6.1: minimized 27KB

    Even hosted on one's own servers, with proper caching the first request should be good for many subsequent requests, so the 78KB hit from jQuery UI is spread out over time.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2015
    Location
    Canada
    Posts
    24
    Rep Power
    0
    And if you are really worried about the CDN, you could do a fallback for a local version like this for jQuery:

    Code:
       <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
      <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

    Comments on this post

    • requinix agrees : good idea

IMN logo majestic logo threadwatch logo seochat tools logo