Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Modernizr is not defined"

My app includes Modernizr (concatenated with prefixfree) just before the closing <head> tag, and the rest of the js just before the closing <body> tag. 99.9% of the time this works fine, but sometimes I get Modernizr is not defined.

The code causing the error is:

if(!Modernizr.csscalc) {
  // do stuff
}

This error happens on real clients (I get notifications by email), so I don't have much more data than this error string. I also fail to reproduce it, even on same OS and browser.

I have no clue for what may be the cause of this sporadic error. Could you please direct me? Am I doing something wrong here?

like image 703
Tzach Avatar asked Nov 11 '22 10:11

Tzach


1 Answers

There could be a number of different reasons why this is happening.

As Felix mentioned, the file itself may not have loaded (you should have file timeouts tracked on your analytics setup as well, if you don't already).

Another possibility is that Modernizr itself had problems and threw an error due to issues with a specific browser (can easily be true with older and cutting edge versions of it). First thing would be to make sure you are running the most up to date version of the library, second would be to report any pattern you see upstream to Modernizr's github page.

like image 164
Patrick Avatar answered Nov 14 '22 23:11

Patrick