I'm using a CDN to Load Bootstrap.css. My question is how can i check if CDN bootstrap was loaded/found. And if it wasn't, then load local Boostrap.
Here's Jquery fallback..
<script type="text/javascript">
Modernizr.load([
{
load: '//cdnjs.cloudflare.com/ajax/libs/jquery/1.10.1/jquery.min.js',
complete: function () {
if ( !window.jQuery ) {
Modernizr.load([
{
load: config.js + 'vendor/jquery-1.10.1.min.js',
complete: function () {
console.log("Local jquery-1.10.1.min.js loaded !");
}
}
]);
} else {
console.log("CDN jquery-1.10.1.min.js loaded !");
}
}
}
]);
</script>
And this is how i load Modernizr than Css:
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<script type="text/javascript">
if (typeof Modernizr == 'undefined') {
document.write(unescape("%3Cscript src='" + config.js + "/vendor/modernizr-2.6.2-respond-1.1.0.min.js' type='text/javascript'%3E%3C/script%3E"));
console.log("Local Modernizer loaded !");
}
</script>
<script type="text/javascript">
Modernizr.load([
{
load: config.css + "bootstrap.css",
complete: function () {
console.log("bootstrap.css loaded !");
}
},
{
load: config.css + "responsive.css",
complete: function () {
console.log("responsive.css loaded !");
}
},
{
load: config.css + "icons.css",
complete: function () {
console.log("Fontello icons.css loaded !");
}
},
{
load: config.css + "icons-ie7.css",
complete: function () {
console.log("Fontello icons-ie7.css loaded !");
}
},
{
load: config.css + "animation.css",
complete: function () {
console.log("Fontello animation.css loaded !");
}
}
]);
</script>
I have no idea how i could check if the css was loaded.. just like i did with modernizr and Jquery..
Thanks in advance...