#33901 closed enhancement (fixed)
Defer embedding Customizer widget controls to improve DOM performance
Reported by: | westonruter | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Customize | Keywords: | has-patch commit |
Focuses: | javascript, performance | Cc: |
Description
In working on a site with a lot of widgets in the Customizer, where these widgets are heavy with lots of inputs, I've found that the Customizer locks up at DOM ready for quite a while as it tries to embed all of the widget controls into the DOM. In a test where I have 100 widgets that each have ~300 inputs each, the Customizer took 40 seconds to finish rendering the page (to allow the user to click around) even it only took PHP half a second to send the HTML for the page.
For the Menu Customizer feature merged in 4.3, there are a lot of nav menu item controls that get added to the Customizer and this introduced a very noticeable performance hit. This was addressed by only embedding the wrapper li
element when the Customizer first loaded, and then to embed the rest of the nav menu item control with all of its UI once the containing menu section was expanded.
We can take this same approach for widgets. First we can defer the embedding of the widget control accordion until the sidebar section is expanded. But then we can also defer the embedding of the actual contents of the widget form until the control itself is expanded.
I have developed a proof of concept for this in a feature plugin: https://github.com/xwp/wp-customize-widgets-plus/pull/32
With the feature plugin active, what used to take 40 seconds to render the page with 100 widgets containing 300 inputs each, it now takes only 3 seconds and there is no perceived browser lockup in the UI.
Attachments (5)
Change History (18)
This ticket was mentioned in Slack in #core by westonruter. View the logs.
9 years ago
#3
@
9 years ago
- Keywords has-patch needs-testing added
- Owner set to westonruter
- Status changed from new to accepted
- Summary changed from Defer embedding widget controls to improve DOM performance to Defer embedding Customizer widget controls to improve DOM performance
- Version set to 3.9
#4
@
9 years ago
This is looking great. Definitely a good call to defer embedding these controls, even without them by JS-driven.
#5
@
9 years ago
33901.3.diff finally adds QUnit test fixtures for widgets in the Customizer, as well as tests specific to the changes introduced here.
If anyone could test out the changes and confirm that the speed improvements are present and regressions are absent, remove the needs-testing
and I'll commit!
Note that the Customize Widgets Plus feature plugin implements the features in this ticket so the performance improvements can be had on 4.3 now: https://github.com/xwp/wp-customize-widgets-plus/pull/32
#7
@
9 years ago
Could someone do a sanity check for the patch and verify all is working as advertised? I'd like to get this committed tomorrow morning. /cc @valendesigns @celloexpressions @voldemortensen
This ticket was mentioned in Slack in #core by westonruter. View the logs.
9 years ago
#10
@
9 years ago
- Keywords commit added; needs-testing removed
The QA team for one of my client projects tested the changes in the feature plugin, and it checked out.
I ran Chrome's memory usage timeline before/after the feature plugin was activated.
Before:
After: