-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curl-css shouldn't wait for readystate == 'complete' #273
Comments
Hey @gerges, Thanks so much for offering to do a PR! 🤘 The last time I checked (which was at least a year ago), I'm a bit concerned about Android, too. I can't test it, atm. Perhaps if Chrome supports I don't understand point 2). Is there a problem? Also, users can set the |
Hey @unscriptable, So option 2 (and my avoiding cssNoWait) comes from my desire to wait for link onload, but not document complete. In my head if we're at the point where onload has fired we are close enough to link application that curls internal deferred could be resolved. Even if the interactive readyState happened before some styles where applied, this is still the point where the browser gives control to the user an it makes the most sense to me to resolve the deferred at this point. Even without curl this is the point where the browser considers things "ready enough" to move forward. If you weren't comfortable breaking backwards compatibility by changing this maybe a secondary config value could be used? cssResloveOnLoad or something? |
Hey @gerges, I understand this may work for your use case, but returning control to user code at this point will break some other people's code. For instance, code that checks If you can devise a test case that shows that the css resource resolves at the right time (i.e. between link onload and document completion), then I welcome your PR. :) The test/issue37.html file shows an example of how to ensure that a css file is loaded. I think you'll have to slow the document down a lot, though, to be able to verify your code executes in the correct time window. Is there a way to slow down the document deterministically? |
Ahhh, I think I understand your motivation better. As long as CSS resources Just to clarify my thinking, a readyState of interactive is when
|
Hey @unscriptable, I didn't have a lot of time today but made a simple test. I've got an express server running with two handlers The test page does the following
I've also patched curl-css to immediately see if the styles are applied when the onload handler is triggered...
So at this point it looks like in Chrome when the link.onload is called the browser has already applied styles (or is immediately doing so). Out of curiosity I completely removed the call to
Here's the code I was using to test. https://github.com/gerges/events-test Do you think this is an acceptable test? If so I'll script it up and send it to BrowserStack to see how other browsers behave. |
If I understand this correctly Chrome has fixed its behaviour (which was the only known browser to have a problem), which would suggest we can remove the work around in curl that waits for (I'm hitting this problem with curl at the moment.) |
Would anybody like to submit a PR that removes the readyState work-around? |
The curl.js CSS plugin currently waits for
document.readyState == 'complete'
before resolving it's deferred. In the comments, it's mentioned that Chrome won't apply styles until this time. I think this wait may be over the top. If a page contains many high resolution images, Chrome would likely have had the time to download/parse/apply the styles long before complete is fired. I'm proposing one of the following optionsreadystate == 'interactive'
(since the document claims to be in an interactive state, allowing background images to continue loading)I was hoping to get some feedback before I worked on a PR, let me know what you think.
The text was updated successfully, but these errors were encountered: