原创

延迟js加载(lazyload 含有jQuery 等很多js时)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    class="csstransforms csstransforms3d csstransitions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script src="./lazyload-min.js" type="text/javascript"></script>
</head>
<body>

<script type="text/javascript" charset="utf-8">
    function loadComplete() {
        //instead of document.read()
        alert("加载js完成");
    }

    function loadscript()

    {

        LazyLoad
        .loadOnce(
        //也可以load
                [
                'xxxx/jquery-1.10.2.min.js',
                'XXX.js',
                'YYY.js' 
                ], //最后一个数组值不加逗号
        loadComplete, "saa", true);

    }
    setTimeout(loadscript, 1000);
    alert("加载js开始");
</script>
</body>

</html>

附件下载:lazyload-min.js

正文到此结束
本文目录