如果我有一个包含以下内容的页面:
1. HTML with text and images.
2. Lots of reference to CSS and Large JS Files.
3. Within HTML a call similar to one below:
$(document).ready(function () {
$.ajax({
url: "http://fiddle.jshell.net/favicon.png",
beforeSend: function( xhr ) {
xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
}
})
.done(function( data ) {
if ( console && console.log ) {
console.log( "Sample of data:", data.slice( 0, 100 ) );
}
});
}
有人能澄清一下我下面的理解是否正确吗?就哪一个先加载而言?
- 加载所有HTML和图像
- 加载CSS并应用CSS样式
- 然后,调用$.ajax调用
- 渲染整个页面
ready
保证在DOM准备好后调用,仅此而已。这肯定不会加载"所有HTML和图像",特别是图像可能已经加载,也可能没有加载。