非同期ロードjsと非同期実行jsの方法

1679 ワード

非同期ロードjs
1. async、defer [H5]
<script type="text/javascript" src="test.js" async="async" defer="defer" ></script>
async:      
defer:             

2. getScript() [jquery]
getScript('test.js',function(response,status){ xxx });
   AJAX            JavaScript   
response -            
status -        ("success", "notmodified", "error", "timeout"   "parsererror"

非同期実行jsメソッド
function fun1(){
    setTimeout(function(){
        fun2();
    },1000);
}
 fun1   1000     fun2