Question

I'm getting a very weird error that only occurs using minified yepnope, but also only when it is injected with jQuery rather than simply shipping with the html. I think it must have to do with the way yepnope gets the document, but then why does only the minified version break? Any ideas what's going on?

The error is this: Uncaught TypeError: Cannot call method 'insertBefore' of null yepnope.1.5.4-min.js:2

<html>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
    //$.getScript("https://raw.github.com/SlexAxton/yepnope.js/master/yepnope.js",function(){ //This works
    $.getScript("https://raw.github.com/SlexAxton/yepnope.js/master/yepnope.1.5.4-min.js",function(){ //This doesn't
        yepnope({
            load:"https://raw.github.com/iloveitaly/jquery.loadmask.spin/master/jquery.loadmask.spin.js"
        });
    });
</script>
</html>

This works just fine

<html>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="yepnope.min.js"></script> //github won't allow me to reuse the raw file here
<script>
    yepnope({
        load:"https://raw.github.com/iloveitaly/jquery.loadmask.spin/master/jquery.loadmask.spin.js"
    });
</script>
</html>
Was it helpful?

Solution

I was able to resolve the problem by minifying the file myself. The minified version on github was out of date. Lesson learned the hard way...

For reference if you have node handy:

sudo npm install uglifyjs -g 
uglifyjs yepnope.js -m > yepnope.min.js 
// Add license in vim..
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top