使用jQuery预加载页面

时间:2017-06-30 14:28:37

标签: jquery html document-ready preloader

我想知道$(window).on('load', function() { ... }中的preload-min.js函数是否在触发之前考虑了index.htmlmain-min.js中的所有代码。

的index.html

<html>
  <body>

    ... html code ...

    <script src="dist/main-min.js"></script>
    <script src="dist/preloader-min.js" charset="utf-8"></script>
  </body>
</html>

主min.js

$(document).ready(function() {

 ... js code ...

})

预压min.js

$(document).ready(function() {
  $(window).on('load', function() {

    ... js code ...

  });
})

1 个答案:

答案 0 :(得分:1)

preloader-min.js将等到index.html中的所有内容都加载完毕。这两个脚本的行为与将它们放在<script>中的一个index.html标记中的行为相同。