I'm new to Modernizr and I'm just looking for a simple way to check for overall browser compatibility. I've generated a Modernizr script to test for only the most essential components of my web application, which is highly dependent on HTML5, CSS3, and modern JavaScript methods. Is there a way to run all of these tests simultaneously? Looking over the documentation, I see plenty of ways to test each feature one by one, but I'm not seeing a way to do it all at once. I'm hoping to do something like this:
Pseudocode
if (Modernizr.testAll()) {
// Load site
} else {
// Redirect to compatibility page
}
It turns out that all the tests are stored as booleans directly in the Modernizr
object, so if you're building an application with a lot of feature dependencies and you want to test them all at once, use this:
var supported = true;
for (var feature in Modernizr) {
if (typeof Modernizr[feature] === "boolean" && Modernizr[feature] == false) {
supported = false;
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With