Should I use Bootstrap from CDN or make a copy on my server?

前端 未结 5 506
终归单人心
终归单人心 2020-11-29 14:32

What\'s the best practice of using Twitter Bootstrap, refer to it from CDN or make a local copy on my server?

Since Bootstrap keeps evolving, I am afraid if I refer

5条回答
  •  余生分开走
    2020-11-29 15:11

    Thanks to @KyleMit. Another way of fall back is using 'window' object as under -

    
    

    It works like this - If the CDN link works, 'window' object will have 'jQuery' property available else the second part of the script i.e. document.write will get executed which points to the local copy.

    Answer to original question - Having CDN has many benefits such as quick downloads without impacting your server and bandwidth. Having a local copy has its own benefit (as a fall back arrangements). On intranet, due to proxy settings, security policies, CDN link may not work or if CDN link is down it may not work. The straight answer is to have both.

提交回复
热议问题