【问题标题】:Error with minified yepnope injected by jQueryjQuery 注入的缩小的 yepnope 错误
【发布时间】:2014-01-07 15:27:46
【问题描述】:

我遇到了一个非常奇怪的错误,该错误仅在使用缩小的 yepnope 时发生,但也仅在使用 jQuery 注入而不是简单地与 html 一起提供时发生。我认为这一定与 yepnope 获取文档的方式有关,但是为什么只有缩小版本会中断?有什么想法吗?

错误是这样的: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>

这很好用

<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>

【问题讨论】:

    标签: jquery dependency-injection yepnope


    【解决方案1】:

    我能够通过自己缩小文件来解决问题。 github 上的缩小版已经过时了。吸取教训的艰辛...

    如果您手边有节点,供参考:

    sudo npm install uglifyjs -g 
    uglifyjs yepnope.js -m > yepnope.min.js 
    // Add license in vim..
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多