Check if Bootstrap is loaded #111

Closed
asapostolov opened this Issue Mar 5, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@asapostolov

How can I check if bootstrap is loaded through your CDN in case there is block to http://www.bootstrapcdn.com/ or something else happens and I need to fallback to a local version of the script?

@jdorfman

This comment has been minimized.

Show comment
Hide comment
@jdorfman

jdorfman Mar 5, 2013

Member

@asapostolov @flashtopia actually wrote a cool little script on issue #110

<!-- BOOTSTRAP JS WITH LOCAL FALLBACK-->
<script type="text/javascript" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>

<script> if(typeof($.fn.modal) === 'undefined') {document.write('<script src="//www.mysite.com/js/v/bootstrap-2.1.1.js"><\/script>')}</script>

<!-- BOOTSTRAP CDN FALLBACK CSS-->
<script>$(document).ready(function() {
var bodyColor = $('body').css("color"); if(bodyColor != 'rgb(51, 51, 51)') {$("head").prepend("<link rel='stylesheet' href='//www.mysite.com/css/fw/bootstrap-combined-2.1.1.css' type='text/css' media='screen'>");}
});</script>
Member

jdorfman commented Mar 5, 2013

@asapostolov @flashtopia actually wrote a cool little script on issue #110

<!-- BOOTSTRAP JS WITH LOCAL FALLBACK-->
<script type="text/javascript" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>

<script> if(typeof($.fn.modal) === 'undefined') {document.write('<script src="//www.mysite.com/js/v/bootstrap-2.1.1.js"><\/script>')}</script>

<!-- BOOTSTRAP CDN FALLBACK CSS-->
<script>$(document).ready(function() {
var bodyColor = $('body').css("color"); if(bodyColor != 'rgb(51, 51, 51)') {$("head").prepend("<link rel='stylesheet' href='//www.mysite.com/css/fw/bootstrap-combined-2.1.1.css' type='text/css' media='screen'>");}
});</script>

@jdorfman jdorfman closed this Mar 5, 2013

@flashtopia

This comment has been minimized.

Show comment
Hide comment
@flashtopia

flashtopia Mar 23, 2013

Contributor

My fallback requires Jquery or Zepto to work. My script is a bit pointless (only for the paranoid), since I have never had any issues with NetDNA CDN or bootstrapcdn.com.

If you are going to be this paranoid, maybe a good idea is to host all your static content on NetDNA and then fallback all css / js / img files with local items. @asapostolov let me know if this is what you are trying to do and ill write a function that forces fallbacks if the CDN script is unreachable.

Another option would be to use your own DNS failover and CDN account. Say you have yourzone.netdnacdn.com but are worried about it failing. You could sign up for a service such as DNSmadeEasy.com which supports DNS failover. If yourzone.netdnacdn.com (cname) fails it can then covert the cname to pull from your server. Zerigo DNS also has this functionality.

Contributor

flashtopia commented Mar 23, 2013

My fallback requires Jquery or Zepto to work. My script is a bit pointless (only for the paranoid), since I have never had any issues with NetDNA CDN or bootstrapcdn.com.

If you are going to be this paranoid, maybe a good idea is to host all your static content on NetDNA and then fallback all css / js / img files with local items. @asapostolov let me know if this is what you are trying to do and ill write a function that forces fallbacks if the CDN script is unreachable.

Another option would be to use your own DNS failover and CDN account. Say you have yourzone.netdnacdn.com but are worried about it failing. You could sign up for a service such as DNSmadeEasy.com which supports DNS failover. If yourzone.netdnacdn.com (cname) fails it can then covert the cname to pull from your server. Zerigo DNS also has this functionality.

@MikeiLL MikeiLL referenced this issue in MikeiLL/mz-mindbody-api Sep 17, 2014

Closed

Conflict if Bootstrap already Loaded #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment