【发布时间】: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