What is the difference between these jQuery ready functions?

后端 未结 9 1520
名媛妹妹
名媛妹妹 2020-11-22 15:31

what is difference between

$(function(){

}); 

and

$(document).ready(function() { 

});
9条回答
  •  Happy的楠姐
    2020-11-22 15:53

    } else if (jQuery.isFunction(selector)) {
        return rootjQuery.ready(selector);
    }
    

    From the source

    Calling $(document).ready(selector) saves a few if statements.

    Although jQuery does cache $(document) internally that might make $(f) faster.

    Benchmarked

提交回复
热议问题