Page MenuHomePhabricator

Standardize page-loaded event across stable/beta/alpha
Closed, ResolvedPublic


Author: jgonera

We need a standard event which is fired in every mode (stable/beta/alpha) when a page is ready for modules to bind to. Right now we have:

M.on( 'page-loaded', ... );
$( ... );
M.define( 'module', {

init: ...

} ); // and mwMobileFrontendConfig.settings.initOnDefine

We should probably just leave the first one and make it consistent in every mode.

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:18 AM
bzimport set Reference to bz45299.
bzimport created this task.Feb 23 2013, 1:31 AM

Due to the way ResourceLoader works there is no way to trigger a page-loaded event on the first page.

I thus suggest that

  • page-loaded event should only fire for lazy loaded page

Therefore modules can either run (on initially loaded pages) or future loaded pages.

  • We should probably just run code for the intially loaded page. e.g. init(); Previously this created problems with tests which couldn't cope with modules self initialising (hence existence of mw.config.set( 'wgInitOnDefine', false ); ) but hopefully this is less of a problem now.

I guess this will go with the death of the ajax loading feature.

Change 164141 had a related patch set uploaded by Jdlrobson:
WIP: Remove all the ajax related things.

Change 164141 merged by jenkins-bot:
Remove all the ajax related things.