When the ext.3d module arrives in a big batch from the server, the initial registration of its code already does quite a lot of work.
- All of the DOM work should be deferred.
- Most of the DOM work should also be made conditional, given the computed values are actually unused in most cases.
- Check if it is feasible to only load this module on pages that feature 3D files. It is currently loaded on all page views, for all users, in all namespaces. It should probably be queued by the thumbnail handler or from a parser hook in some way so that it is only loaded on pages that contain 3D media.
- Only load JS on File:pages
- Only load JS/CSS on pages with 3D media
The above performance timeline fragment is found on all page views. The vast majority of the time is actually spent on a single line of code, included below (coloured in pink above). The remaining 99% of the code that ext.3d module executes is too small to register in the graph and not a concern at this time.
$placeholderTemplate: $( '<span>' ) .addClass( 'mw-3d-thumb-placeholder' ) .text( ' ' + mw.message( '3d-thumb-placeholder' ).text() ) .prepend( $.createSpinner( { size: 'small', type: 'inline' } ) ),
Ref 112f1330f54, T187327, https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/3D/+/410457/.