Page MenuHomePhabricator

Reduce footprint of ext.3d on page initialisation
Closed, ResolvedPublic

Description

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

Screen Shot 2018-09-17 at 05.05.08.png (376×2 px, 94 KB)

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/.

Event Timeline

Krinkle created this task.

1 & 2 should be easy. 3 is probably blocked on T187562.

Change 461176 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/3D@master] Lazy-build the placeholderTemplate

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

Change 461176 merged by jenkins-bot:
[mediawiki/extensions/3D@master] Lazy-build the placeholderTemplate

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

Change 461249 had a related patch set uploaded (by Krinkle; owner: Esanders):
[mediawiki/extensions/3D@wmf/1.32.0-wmf.22] Lazy-build the placeholderTemplate

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

Change 461404 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/3D@master] Only load 3D JS on file page

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

Change 461249 merged by jenkins-bot:
[mediawiki/extensions/3D@wmf/1.32.0-wmf.22] Lazy-build the placeholderTemplate

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

Mentioned in SAL (#wikimedia-operations) [2018-09-20T00:52:28Z] <krinkle@deploy1001> Synchronized php-1.32.0-wmf.22/extensions/3D/modules/: I9e718957a497, T204621 (duration: 00m 58s)

Change 461404 merged by jenkins-bot:
[mediawiki/extensions/3D@master] Only load 3D JS on file page

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

Change 483760 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/3D@master] Fix selector to not check extension

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

Change 483760 merged by jenkins-bot:
[mediawiki/extensions/3D@master] Fix selector to not check extension

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

Jdforrester-WMF updated the task description. (Show Details)
Jdforrester-WMF subscribed.

Can we declare this Resolved?