如果我在页面中有一个很大的 css 文件,那么我的 document.ready 执行将等到 css 文件加载或不加载。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="large-amount-file.css">
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<p>fsdfsd</p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
alert("hi");
});
</script>
</body>
</html>
最佳答案
$(document).ready
在 HTML 文档加载且 DOM 准备就绪时执行
$(window).load
在整个页面完全加载时执行,包括所有框架、对象和图像。
这么大的 CSS 文件不会阻塞 $(document).ready
函数。
关于jquery - css会阻塞文档准备功能吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36217215/