#jQuery CSS Fallback Plugin
This plugin provides a fallback, for example, if you use a CDN for a CSS file. To use it, you need:
- knowledge about the used CSS file,
- knowledge about your page,
- another (probably local) copy of the used CSS file.
The plugin checks if an existing element on the page has been successfully styled (selector, cssRule, cssValue). If not, the fallback CSS file will be attached to the head (cssFallback, probably local).
$.cssFallback({
'selector': '.classname',
'cssRule': 'background-color',
'cssValue': 'green',
'cssFallback': 'url/to/fallback.css'
});
Returns true
if the fallback was used, false
, if not.
One problem with this plugin is, that if it kicks in, the order of the CSS files is changed, which could harm the styling. As a work-around, you can read the return value and reload the css files which need to be loaded after the tested file.
- Parameters not using an object.
- Example.
- Tests.
- IE 8
- IE 11
- Chrome 34
- FireFox 26
Ludger A. Rinsche.
Released under MIT license.