With current implementation, a lightweight JavaScript startup module is first loaded (startup.js) which tests browser user agent and then triggers a download of MediaWiki and jQuery.
When these have finished downloading, a call to mw.loader.load is triggered that downloads another JavaScript URL. As a result we make 3 JavaScript requests.
I did wonder, what is blocking us from merging the last 2, e.g. making the startup module do something like this:
script = document.createElement( 'script' ); script.src = document.documentElement.getAttribute( 'data-script' );
instead of
script = document.createElement( 'script' ); script.src = $VARS.baseModulesUri;
I am sure there are cache considerations and this will fragment the cache for some pages, but our time to first byte is costly and it looks like this would save our users up to 2s for each JavaScript request we avoid.
On mobile on a cold cache there are currently 5 script requests (startup module, mediawiki/jquery, top loaded scripts, bottom loaded scripts and a CentralAuth script). What's stopping us at the very least merging top loaded scripts with mediawiki/jquery ?