To make the images load faster, we should add a resource hint, making the browser preconnect to upload.wikimedia.org. Preconnect in this case means the browser will do DNS+TCP+TLS as soon as it cann for that domain and hopefully a little earlier than today.
To do that, we need to add:
<link rel="preconnect" href="//upload.wikimedia.org ">
Note: we should use the header variant instead of adding the link tag to the DOM, as Edge only supports the header version.
Here's an example of how it looks today.
Preconnect is supported by Chrome, Firefox and Opera on Desktop and Chrome & Android Browser on Android (http://caniuse.com/#feat=link-rel-preconnect).
Quick draft to show the syntax of preconnect: https://gerrit.wikimedia.org/r/#/c/348807/4/includes/OutputPage.php
MediaWiki ParserOutput doesn't currently track the effective image url(s). Only the file names. Extracting the host from File::getPath() manually is tricky because file path to original file and thumbnail may differ. E.g. when using a foreign repository like Wikimedia Commons, some configurations host thumbnails in the local file backend (instead of "hot linking").