I want to load my website CSS asynchronously. I want to know if jQuery.ready()
function will run after the async load of the CSS is completed or will jQuery ignore it and the CSS might finish loading after jQuery.ready()
function starts running.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
jQuery.ready() runs when the DOM has been loaded.
If you wish to load some CSS asynchronously, then your best bet would be to insert link tag in the head in the ready callback.
In other words...
Hope it helps!
Try utilizing
$.holdReady()
Short answer - no.
$(document).ready()
will not wait for asynchronous loading to finish. It will fire as soon as DOM is loaded.Normally you would put
async
loading functions inside(document).ready()
so they start executing as soon as they safely can. It's a little weird that you're trying to perform async CSS loading before the DOM.$(document).ready()
is an event-trigger function. It's cannot be made to wait.Please elaborate on what exactly you are trying to accomplish.
P.S. Please read this "execution sequence" answer: Load and execution sequence of a web page?