-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Synchronous script loading during HTML parsing #3721
Conversation
Critic review: https://critic.hoppipolla.co.uk/r/2904 This is an external review system which you may optionally use for the code review of your pull request. In order to help critic track your changes, please do not make in-place history rewrites (e.g. via |
585b7cf
to
b807bcb
Compare
Possibly intermittent?
|
This implements the parts of the "prepare a script element" algorithm that are required for synchronous scripts. It also adds some infrastructure for future support of the `async` and `defer` attributes.
This removes the old code for asyncronously loading scripts during HTML parsing and then executing them afterward. Fixes servo#3356.
This fixes a performance regression caused by the previous patches. Once we allowed script and layout to run during parsing, it was running too often (every time the document changed and called window.reflow). Fixes servo#1269.
// the origin of the script element's node document, and the default origin | ||
// behaviour set to taint. | ||
match load_whole_resource(&page.resource_task, url) { | ||
Ok((metadata, bytes)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the JS event loop get to spin while this happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this blocks the script thread. We need to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #4088.
Fixes #3356. This makes script elements fetch their source synchronously and execute immediately by default. It also lays some groundwork for future deferred or async script loading.
(Depends on #3716 to fix a content test failure caused by running script during parsing.)