diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 380a722591..ec61263877 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -1859,6 +1859,28 @@ touchDrag: false, + /** + * Defer rendering the theme control until the section is displayed. + * + * @since 4.2.0 + */ + renderContent: function () { + var control = this, + renderContentArgs = arguments; + + api.section( control.section(), function ( section ) { + if ( section.expanded() ) { + api.Control.prototype.renderContent.apply( control, renderContentArgs ); + } else { + section.expanded.bind( function ( expanded ) { + if ( expanded ) { + api.Control.prototype.renderContent.apply( control, renderContentArgs ); + } + } ); + } + } ); + }, + /** * @since 4.2.0 */