Open
Description
With the following HTML
<script src="long-download.js" defer></script>
<script src="short-download.js" defer></script>
If short-download.js
has finished being fetched before long-download.js
then both will execute in the same task.
This is visible in a Glitch demo (with 3 scripts in the same task) Glitch project to remix
Use case
While trying to split our code into several smaller scripts to prevent long blocking tasks, we noticed some defer scripts would sometime run in the same task, defeating the purpose of our "optimisation". The "sometime" was the race condition described here (that can happen because of network conditions or caches).
(conversation started in a Twitter thread with @jakearchibald)