/** * Drop the theme's heavy jquery-ui.js globally, * then conditionally enqueue only the core modules when needed. */ add_action('wp_enqueue_scripts', function () { // This handle comes from your Query Monitor list wp_dequeue_script('jquery-ui'); // theme handle wp_deregister_script('jquery-ui'); // theme handle }, 100); /** * Example: only enqueue datepicker on pages that really use it. * Adjust the condition to your real use case. */ add_action('wp_enqueue_scripts', function () { if (is_page('contact') || is_page('book-appointment')) { wp_enqueue_script('jquery-ui-datepicker'); // WP core, small // If you need a theme init JS for the datepicker, enqueue it here too } }, 110);