Score:0

Why am I seeing Modernizr JavaScript errors on page load?

in flag

When I load pages on our live site (D9), we see these Modernizr errors from contextual links JS, and the contextual links don't appear on the site.

Chrome JS Console output

However, Modernizr does appear to be loaded ahead of the contextual links JS, as you can see from the two further screen captures, so I don't see why RegionView and VisualView should think it is undefined.

Modernizr load time Region View load time

and also the Modernizr object is available in the JS console after page load

Modernizr object in console

I have no idea how to progress solving this. To make things worse, this doesn't seem to happen on our test sites, which are running on the same codebase.

cn flag
Are the scripts loaded async? If so the order you’re seeing might be request start, not request end
Monkeybrain avatar
in flag
Thank you for the suggestion Clive. I don't believe they are loaded async from looking at the HTML, plus my understanding (which might be wrong, I am no expert in this) is that the Timing panel in the screen grabs shows that modernizr request was completed before the RegionView request started?
apaderno avatar
us flag
It says *Started at 1.73 s* and *Started at 3.16 s*, which means that RegionView.js was received after receiving modernizr.js. It seems they are asynchronous calls since they are queued at 1.63 s and 1.68 s.
Monkeybrain avatar
in flag
Thank you Apaderno, does that mean modernizr would have been loaded by the time RegionView attempted to reference it, or might there be other reasons why it wasn't?
apaderno avatar
us flag
That depends from what the code does after asynchronously loading the files. If it waits for the files to be loaded, it should not say that `Modernizr` isn't defined.
Monkeybrain avatar
in flag
I cannot see any 'waiting' happening but I do not really understand how all this stuff works. As far as I can see the RegionView code just assumes the Modernizr object is available, there is no checking that it is loaded. Is there some way I can force a dependency, maybe through YML files?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.