Question

When yepnope (which comes by default bundled in Modernizr) is used on a GreaseMonkey userscript that @runs-at document-start, the whole userscript fails with the error "n is undefined", which means maxified that "firstScript is undefined".

Indeed it refers to the line: insBeforeObj = isGeckoLTE18 ? docElement : firstScript.parentNode,

Was it helpful?

Solution

Since the DOM is not yet loaded at GreaseMonkey document-start, this fails.

Workaround 1: Don't use yepnope with Modernizr, this isn't mandatory.

Workaround 2: Run Modernizr/yepnope at document-end. That's probably where you're starting to manipulate the DOM, aren't you?

document.addEventListener('DOMContentLoaded', _runAtDocumentEnd, false);

function _runAtDocumentEnd() {

/* insert Modernizr/Yepnope library here */

}

Workaround 3: Run at document-end. But since you've explicitely wanted to run it at document-start, this is probably not an acceptable workaround.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top