Skip to content

Core: Fixed race condition caused by deferring the script #2103

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Oct 25, 2019

Conversation

RunDevelopment
Copy link
Member

As discussed in #2102.

I'll make a different PR for the currentScript issue.

@RunDevelopment
Copy link
Member Author

You can verify that this indeed fixes the race condition by replacing prism.min.js in the test page by @BrainStone with <script defer src="http://localhost/prism.js"></script> (localhost being this PR).

You'll see that the race condition is no more.

@mAAdhaTTah
Copy link
Member

Def going to want a code comment in there explaining a bit of why this is necessary.

@RunDevelopment
Copy link
Member Author

Comment as requested.
I also added readyState === 'interactive' to the condition because if the readyState === 'complete' then the script can be deferred all it wants, DOMContentLoaded has already been fired.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants