我创建了以下脚本,结合我对JS的理解,以及对lazyload.js、head.js、yepnope.js等流行脚本的一些研究...
我需要它以非阻塞方式加载 javascript 文件,我需要它很短,要内联使用它,它需要是纯 javascript。它适用于 Chrome 和 Firefox,但它在 IE 9 及以下版本上中断(不尊重顺序),可能是什么问题?
lazyLoader = {
    load: function (scripts) {
        lazyLoader.nodes = []
        lazyLoader.queue = [scripts];
        for (i = 0; i < lazyLoader.queue[0].length; ++i) {
            var element = document.createElement("script");
            element.type = "text/javascript"
            element.src = lazyLoader.queue[0][i];
            element.async = false;
            element.defer = true;
            element.onload = function () {
                this.onload = null;
            }
            element.onreadystatechange = function() {
                if (this.readyState == "loaded" || this.readyState == "complete" ) {
                    this.onreadystatechange = null;
                    lazyLoader.loaded();
                    console.log ("The script ", this.src, " is ready!")
                }
            }
            lazyLoader.nodes.push(element) 
        }
        for (i = 0; i < lazyLoader.nodes.length; ++i) {
            console.log ("The script ", lazyLoader.nodes[i].src, " will be appended.")
            document.body.appendChild(lazyLoader.nodes[i])
        }
    },
    loaded: function() {
        console.log ("Loaded")
    }
}