resourceloader: Combine base modules and page modules requests


resourceloader: Combine base modules and page modules requests

This commit implements step 4 and step 5 of the plan outlined at T192623.

Before this task began, the typical JavaScript execution flow was:

  • HTML triggers request for startup module (js req 1).
  • Startup module contains registry, site config, and triggers a request for the base modules (js req 2).
  • After the base modules arrive (which define jQuery and mw.loader), the startup module invokes a callback that processes RLQ, which is what will request modules for this page (js req 3).

In past weeks, we have:

  • Made mediawiki.js independent of jQuery.
  • Spun off 'mediawiki.base' from mediawiki.js – for everything that wasn't needed for defining mw.loader.
  • Moved mediawiki.js from the base module request to being embedded as part of startup.js.

The concept of dependencies is native to ResourceLoader, and thanks to the
use of closures in mw.loader.implement() responses, we can download any
number of interdependant modules in a single request (or parallel requests).
Then, when a response arrives, mw.loader takes care to pause or resume
execution as-needed. It is normal for ResourceLoader to batch several modules
together, including their dependencies.

As such, we can eliminate one of the two roundtrips required before a
page can request modules. Specifically, we can eliminate "js req 2" (above),
by making the two remaining base modules ("jquery" and "mediawiki.base") an
implied dependency for all other modules, which ResourceLoader will naturally
fetch and execute in the right order as part of the batch request.

Bug: T192623
Change-Id: I17cd13dffebd6ae476044d8d038dc3974a1fa176


KrinkleAuthored on Jul 12 2018, 8:09 PM
rMW4d3b6f213e13: Merge "easydeflate.js: Use LF instead of CRLF as newline"