Page MenuHomePhabricator

Pre-fetch VisualEditor modules to improve load speed
Closed, DeclinedPublic8 Estimated Story Points

Description

First impressions count! You can make the initial experience of loading VE substantially faster by prefetching the modules on a standard article page if the DOM isn't busy.

What I have in mind is something like this:

$( window ).load( function () {
    if ( !mw.loader.store.enabled ) {
        return;
    }

    setTimeout( function () {
        var modules = [
            'ext.visualEditor.base',
            'ext.visualEditor.core'
            'ext.visualEditor.data',
            'ext.visualEditor.icons-vector',
            'ext.visualEditor.mediawiki',
            'ext.visualEditor.viewPageTarget',
            'ext.visualEditor.viewPageTarget.icons-vector',
        ]

        mw.loader.using( modules.filter( function ( module ) {
            var key = mw.loader.store.getModuleKey( module );
            return key in mw.loader.store.items;
        } ) );

    }, 0 );
} );

You'd need to ensure that the modules don't execute automatically somehow.


Version: unspecified
Severity: enhancement

Details

Reference
bz57952

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:15 AM
bzimport set Reference to bz57952.

It's fine for them to execute automatically, nothing happens until .activate() is invoked.

Jdforrester-WMF renamed this task from VisualEditor: Pre-fetch modules to improve speed for end-users to Pre-fetch VisualEditor modules to improve speed for end-users.Dec 2 2014, 9:40 PM
Jdforrester-WMF set Security to None.
Krenair subscribed.

Roan says there should be some infrastructure in RL to do this.

Krenair renamed this task from Pre-fetch VisualEditor modules to improve speed for end-users to Pre-fetch VisualEditor modules to improve load speed.Apr 17 2015, 6:06 PM
ori claimed this task.

I'll challenge my own contention from 2013:

You can make the initial experience of loading VE substantially faster

Probably not. For all but the slowest of connections, VE load time is dominated by the cost of fetching the Parsoid DOM, building the linear model, and then building the ContentEditable DOM from the linear model. The cost of retrieving the JavaScript and CSS is negligible in comparison.

This may or may not be worth doing, but in the absence of good data, there is no strong case for doing this work, so I'm closing this for now.