Modernizr Yepnope Css Fallback-Collection of common programming errors
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..
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 !");
}
}
}
]);
And this is how i load Modernizr than Css:
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 !");
}
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 !");
}
}
]);
I have no idea how i could check if the css was loaded.. just like i did with modernizr and Jquery..
Thanks in advance…
Originally posted 2013-11-29 06:07:01.