Page MenuHomePhabricator

Make ResourceLoader a standalone library
Open, LowPublic

Description

Frontend

mw.loader is naturally quite separate from other MediaWiki JS modules. Mainly, because it has to - it's the first thing that loads.

  • Implement an abstraction for mw.loader (e.g. factory function or class)? Or find another way to inject MW-specific config (e.g. where load.php is mounted).
  • ???

Progress:

Backend

When ResourceLoader was first written, and shortly before this task was filed, it was mostly MW-agnostic.

Having said that, a few things have crept in over the years.

Original task description

Just like the backend, the front-end should be less tied into MediaWiki base as well.
It sounds more complicated than it really is though. All we need to do is move mw.loader into a separate file and create an instance of it in mw.loader.
It's already an object constructor, except that right now it is instantly-instantiating an anonymous object constructor (this.loader = new (function(){ ... }));

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Issues:

  • Loader uses mw.log, mw.html, mw.messages, mw.config (skin, wgUserLanguage, debug, wgResourceLoaderMaxQueryLength)

mw.html.escape is easily re-created.

The ResourceLoader object constructor would take an option object:
mw.loader = new ResourceLoader({

log: mw.log,
msgStore = mw.messages.values
..

});

Last year that sounded do-able, but today we also have custom load sources and callback queue. So it gets a little more complicates. Though using $.Callbacks() might make some of that easier (if we want to depend on jQuery for the core loader framework).

Both in the design and implementation we've done pretty well in keeping ResourceLoader independent from MediaWiki, but it has been integrated a little bit here and there.

I hope to have some time next quarter to separate the last bits out and move it to its own project with a documented API and release/version policy.

Krinkle raised the priority of this task from Lowest to Low.Dec 1 2014, 9:54 PM
Jdforrester-WMF removed Krinkle as the assignee of this task.Feb 21 2015, 12:20 AM
Jdforrester-WMF added a project: Librarization.
Jdforrester-WMF set Security to None.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 23 2015, 9:38 AM
Krinkle moved this task from Untriaged to To Do on the Librarization board.Sep 4 2015, 4:06 AM
Restricted Application added a project: Performance-Team. · View Herald TranscriptApr 13 2018, 2:47 PM

Change 491018 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Instantiate main class via ServiceWiring

https://gerrit.wikimedia.org/r/491018

Change 491018 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Instantiate main class via ServiceWiring

https://gerrit.wikimedia.org/r/491018

Krinkle closed this task as Resolved.Feb 19 2019, 4:01 AM
Krinkle claimed this task.

@Krinkle Just want to clarify, was this intentionally mark as resolved or was it an accident? There was a patch above, which only mentioned:
“Making ResourceLoader a standalone library (some day)” (as something that is now possible to do in the future). This part mentioned actually hasn’t been done yet, so I don’t think it’s valid to mark this task as resolved. Thank you (and thank you for the patch!)

Krinkle reopened this task as Open.Feb 22 2019, 5:09 PM
Krinkle removed Krinkle as the assignee of this task.Feb 22 2019, 9:17 PM

Change 495306 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Replace ResourceLoaderDebug config use with context

https://gerrit.wikimedia.org/r/495306

@SamanthaNguyen Accidental indeed. This'll be an on-going process in various small steps.

Change 495306 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Replace ResourceLoaderDebug config use with context

https://gerrit.wikimedia.org/r/495306

Krinkle updated the task description. (Show Details)Mar 15 2019, 8:44 PM
Krinkle updated the task description. (Show Details)
Krinkle updated the task description. (Show Details)Mar 15 2019, 8:47 PM
Krinkle updated the task description. (Show Details)

Change 499954 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Move registering of custom sources to ServiceWiring

https://gerrit.wikimedia.org/r/499954

Change 499954 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Move registering of custom sources to ServiceWiring

https://gerrit.wikimedia.org/r/499954

Change 501961 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Move registration of Resources.php to ServiceWiring

https://gerrit.wikimedia.org/r/501961

Change 501961 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Move registration of Resources.php to ServiceWiring

https://gerrit.wikimedia.org/r/501961

Change 503132 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Remove needless MW-specific fallback

https://gerrit.wikimedia.org/r/503132

Change 503133 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Deprecate ResourceLoaderContext::getConfig and ::getLogger

https://gerrit.wikimedia.org/r/503133

Change 503132 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Remove needless MW-specific fallback

https://gerrit.wikimedia.org/r/503132

Change 504561 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Move remaining module registrations to ServiceWiring

https://gerrit.wikimedia.org/r/504561

Change 504561 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Move remaining module registrations to ServiceWiring

https://gerrit.wikimedia.org/r/504561

Change 504660 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@wmf/1.34.0-wmf.1] resourceloader: Move remaining module registrations to ServiceWiring

https://gerrit.wikimedia.org/r/504660

Change 504660 merged by jenkins-bot:
[mediawiki/core@wmf/1.34.0-wmf.1] resourceloader: Move remaining module registrations to ServiceWiring

https://gerrit.wikimedia.org/r/504660

Change 516277 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Warn on ResourceLoader::construct without Config

https://gerrit.wikimedia.org/r/516277

Change 516277 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Warn on ResourceLoader::construct without Config

https://gerrit.wikimedia.org/r/516277

Krinkle updated the task description. (Show Details)Jun 13 2019, 5:31 PM
Krinkle updated the task description. (Show Details)
Krinkle updated the task description. (Show Details)

Change 503133 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Deprecate ResourceLoaderContext::getConfig and ::getLogger

https://gerrit.wikimedia.org/r/503133

Change 517873 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Switch Xml::encodeJsCall call in getDeprecationInformation

https://gerrit.wikimedia.org/r/517873

Change 517873 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Switch Xml::encodeJsCall call in getDeprecationInformation

https://gerrit.wikimedia.org/r/517873

Krinkle updated the task description. (Show Details)Jul 14 2019, 7:27 PM

Change 523371 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@master] resourceloader: Replace some Xml::encodeJs calls with RL's own encodeJson

https://gerrit.wikimedia.org/r/523371

Change 523371 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Replace some Xml::encodeJs calls with RL's own encodeJson

https://gerrit.wikimedia.org/r/523371

Change 535354 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/core@master] resourceloader: Replace Xml::encodeJsCall by encodeJsonForScript

https://gerrit.wikimedia.org/r/535354

Change 535354 merged by jenkins-bot:
[mediawiki/core@master] resourceloader: Replace Xml::encodeJsCall by encodeJsonForScript

https://gerrit.wikimedia.org/r/535354