[removed] and $(document).ready

后端 未结 4 1342
囚心锁ツ
囚心锁ツ 2020-12-14 14:50

According to http://caniuse.com/script-defer, most browsers support the script tag\'s defer attribute.

I would like to know if scripts spec

4条回答
  •  盖世英雄少女心
    2020-12-14 15:47

    Simply, script should be executed before $(document).ready() whether defer is used or not and almost all major browsers support defer.

    But for being safe side I encourage you to use both $(document).ready() and defer. So why defer? Because it helps page appear quickly (as external script is loaded parallel) and a really important factor in Google's page speed tool, a good detail can be found here http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS

提交回复
热议问题