MediaWiki is currently using
<script async="" src="/w/load.php?lang=nl&modules=startup&only=scripts&raw=1"></script>
Looking at w3schools that seems to be invalid syntax. Everywhere where I've seen the async keyword so far it's just been a simple async keyword. No = and no ="". Could that be a bug? Dunno if a separate ticket for that is worth it. What I was actually wondering about...
Could you please consider using the defer keyword rather than the async if that is better for performance. Why? While async sounds nicer, it keeps the browser more busy with parsing. With defer the JavaScript will only be executed after the HTML parsing finished. The advantage of defer is to reduce blocking.
I haven't seen this discussed before here.
Some articles I was reading on the subject and found informative:
- https://zellwk.com/blog/javascript-async-and-defer/
- https://kadiska.com/how-to-minimize-the-performance-impact-of-your-javascripts-by-using-defer-or-async-attributes/
Specifically useful I found these images:
- async: https://kadiska.com/wp-content/uploads/2020/12/async-with-stop-parsing-1024x275.png
- defer: https://kadiska.com/wp-content/uploads/2020/12/defer-1024x337.png
My suggestion is inspired by PageSpeed insights.
The Critical Request Chains below show you what resources are loaded with a high priority. Consider reducing the length of chains, reducing the download size of resources, or deferring the download of unnecessary resources to improve page load.
And /w/load.php?lang=nl&modules=startup&only=scripts&raw=1 is the initiator or another load.php JavaScript request. So it's a chain of 3. HTML document -> load.php 1 -> load.php 2.
Similar to T107399.
Edit:
To add further, potentially more authoritative sources, see this video by Google from minute 12:38 on the topic of defer, quote:
Scripts that use async may interrupt the browser from rendering other parts of the DOM.
Defer is more polite. It will also tell the browser that it can download and process all the stuff on the page, but it won't interrupt the browser to be executed. It will run after the page has been fully parsed. Defer is a great idea for anything that isn't critical for our initial viewport, things like libraries, video ...