[英]Event which triggers when stylesheets, not only the DOM, are loaded on the page
I tried to use the http://api.jquery.com/ready/ callback for executing a code, which I would like to get started only when the page is fully loaded. 我尝试使用http://api.jquery.com/ready/回调执行代码,只有在页面完全加载后,我才想开始使用该代码。 However, this triggers when the DOM is loaded, and it can often happen that the stylesheets are not loaded fully. 但是,这会在加载DOM时触发,并且经常发生样式表未完全加载的情况。
How can I ensure that a particular code is loaded after DOM and also the stylesheets (or even everything) are loaded? 如何确保在DOM之后加载特定的代码以及样式表(甚至所有内容)是否加载? I found some similar questions (like this one ), but they are not about stylesheet loading, which I am particularly interested in. 我发现了一些类似的问题(例如这个问题),但是它们与样式表加载无关,我对此特别感兴趣。
Thanks for suggestions. 感谢您的建议。
I first thought of RequireJS but it appears they have specific reasons why it wouldn't work well. 我首先想到RequireJS,但似乎他们有特定的原因导致它无法正常运行。 http://requirejs.org/docs/faq-advanced.html#css http://requirejs.org/docs/faq-advanced.html#css
They do offer a possible hack "Some people have implemented an approach where they look for a well known style to be applied to a specific HTML element to know if a style sheet is loaded." 他们确实提供了一个可能的技巧:“有些人已经实现了一种方法,即他们将一种众所周知的样式应用于特定的HTML元素,以了解是否加载了样式表。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.