Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Page MenuHomePhabricator

Slideshow and AjaxQuickDelete gadgets load jQuery UI on Special pages
Open, Needs TriagePublic

Description

It looks like some globally-enabled gadgets on Commons (ext.gadget.Slideshow and ext.gadget.AjaxQuickDelete) are loading the jquery.ui library (which weighs ~350KB) on all pages on Commons – even on Special pages where they aren't being used.

I discovered this when looking at ways to optimize the performance of the new Special:MediaSearch page (see T271996). The QuickDelete help page states that the gadget won't be loaded on special pages, but this doesn't seem to be accurate any more.

Addressing this would save a lot of unnecessary JavaScript from being downloaded & executed in places where it won't provide any benefits to the user.

These are community-maintained gadgets so discussion and any potential changes will probably need to happen on-wiki; I'm creating this ticket to remind myself (and give others who may be interested visibility into the issue).

Event Timeline

Gadgets don't have a way to conditionally load themselves (apart from the mostly-static evaluation based on user preferences, user rights, and current skin).

The current way that the community tends to optimise high-visibility gadgets is to either:

  1. Lazy-load dependencies. Move the gadgets dependencies from being static in Gadgets-definition to dynamic in the main script via mw.loader.using(), e.g. after its main conditional check for which page to initialise on, often as part of the same callback that waits for $.ready. Something like if ( wanted ) { when( using, ready ).then( init ); }. The gadget's own code would remain unconditionally loaded, but only act on certain pages and only load heavy dependencies when needed.
  2. Lazy-load the whole gadget. Split the gadget, moving both the dependencies and the gadget's own code into a separate hidden gadget, with the original gadget just a dep-free placeholder that calls mw.loader.load() from an if-statement.

See also T31272 and T63007, which have been awaiting resourcing for a few years.

egardner unsubscribed.
egardner subscribed.