Is Modernizr still necessary?

3.9k Views Asked by At

I'm migrating to Bootstrap 5.0.2 and cleaning up the bundling for optimization. With deprecated support for various older browser versions and the fact that Modernizr.js hasn't been updated since 2017, is this line even still necessary?

@Scripts.RenderFormat("<script type=\"text/javascript\" src=\"{0}\" async></script>", "~/bundles/modernizr")
2

There are 2 best solutions below

2
hamid choopani On BEST ANSWER

There is browsers that does not support all HTML5 and CSS3 features. Also more than users, Older versions of a browser are still in use, To display your website properly in users' old browsers, should of Modernizr.js use

2
Miloš Đakonović On

This is more project-specific question.

Maybe it's not necessary at all, thus complete waste of time & efforts when you know who exactly is going to use your work (for example, a closed group of clients with modern hardware and operating systems).

Besides that, it is absolutely wise decision to use Modernizr.

Ask yourself:

  • do you / how do you know you can use some modern (or even not-so-modern) browser feature without leaving a share of your users with nothing

  • can you afford angry user because nothing happens when he clicks on "Start application" or shaming layout failure happens

Case: you are okay with testing and providing fallback but Modernizr seems to you like overkill. You want just "feature" in document.body simple test.

  • is it a good decision to reinvent a wheel of feature testing even if it seems to you that what you are up to is a simple true/false test. Remember, Modernizr often goes way beyond simple tests, because, well, that's precisely what it is made for.