Make WordPress Core


Ignore:
Timestamp:
03/15/2023 11:36:52 AM (9 months ago)
Author:
spacedmonkey
Message:

Widgets: Defer register inline script in WP_Widget_Custom_HTML and WP_Widget_Text.

In [41376] an inline script was added to push idBases for the custom html and text widgets. However, this script is not used unless the widget script is output in the widget screen / customizer. Deferring registering this script until it is needed, results in a faster server response times.

Props spacedmonkey, sakibmd, flixos90, westonruter.
Fixes #57864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/wpWidgetText.php

    r54088 r55553  
    6868        $this->assertSame( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) );
    6969        $this->assertSame( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) );
    70         $this->assertContains( 'wp.textWidgets.idBases.push( "text" );', wp_scripts()->registered['text-widgets']->extra['after'] );
    7170        $this->assertFalse( has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) );
    7271    }
Note: See TracChangeset for help on using the changeset viewer.