如何定义在网页上加载资源的优先级? [英] How to define priority to load resources on the webpages?

查看:116
本文介绍了如何定义在网页上加载资源的优先级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以为网页中的资源定义优先级。
例如如果定义特定的CSS,js或图像首先加载到网页上。
开发语言PHP



谢谢

解决方案


有什么方法可以为网页中的资源定义优先级吗?

不是真的,至少不是100%。



JavaScript文件按指定的顺序加载和执行。



CSS样式表是异步加载的。这意味着它们与其他资源并行加载,并在完成时完成。对于图像也是如此。



如果在所有样式表和图像加载后需要做某些事情,可以使用 JavaScript onload 事件



更多关于执行/加载顺序的信息这个辉煌的答案。


Is there any way to define priority for resources in web pages. e.g. If define the particular css,js or image load first on the web page. Development Language PHP

Thanks

解决方案

Is there any way to define priority for resources in web pages

Not really, at least not 100%.

JavaScript files are loaded and executed in the order they are specified.

CSS style sheets are loaded asynchronously. That means they load in parallel to other resources, and they are done when they are done. The same goes for images.

If you need to do something after all style sheets and images have loaded, you could use the JavaScript onload event.

More about what is executed/loaded in which order in this brilliant answer.

这篇关于如何定义在网页上加载资源的优先级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆