"Modernizr is not defined" happens when you try to reference it somewhere in a code but have not included it previously.
You may have your
if(Modernizer.geolocation)
call before Modernizr is included, or you have not included it at all. There is also a case when Modernizr is included but within asynchronous script (in that case, there might be something like <script src="modernizr.js" async></script>).
How to include Modernizr - the easiest way?
First choose your detects - a set of features your custom built version of Modernizr will test:
https://modernizr.com/download
Than save it as modernizer.js somewhere in your source tree, for example 'js/modernizr.rs'. Include it in a script tag before first Modernizr call. Like:
<script src="js/modernizr.rs"></script>
<script>
if(Modernizer.geolocation){
alert("geolocation is supported");
}
</script>
"Modernizr is not defined" happens when you try to reference it somewhere in a code but have not included it previously.
You may have your
call before
Modernizris included, or you have not included it at all. There is also a case whenModernizris included but within asynchronous script (in that case, there might be something like<script src="modernizr.js" async></script>).How to include Modernizr - the easiest way?
First choose your detects - a set of features your custom built version of
Modernizrwill test: https://modernizr.com/downloadThan save it as
modernizer.jssomewhere in your source tree, for example'js/modernizr.rs'. Include it in ascripttag before firstModernizrcall. Like: