diff --git a/source/wp-content/themes/wporg-main-2022/functions.php b/source/wp-content/themes/wporg-main-2022/functions.php index 72ae61d0..821a72c3 100644 --- a/source/wp-content/themes/wporg-main-2022/functions.php +++ b/source/wp-content/themes/wporg-main-2022/functions.php @@ -18,6 +18,7 @@ * Actions and filters. */ add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' ); +add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\maybe_dequeue_assets' ); add_action( 'init', __NAMESPACE__ . '\register_shortcodes' ); add_filter( 'wp_img_tag_add_loading_attr', __NAMESPACE__ . '\override_lazy_loading', 10, 2 ); add_filter( 'wporg_block_site_breadcrumbs', __NAMESPACE__ . '\update_site_breadcrumbs' ); @@ -25,6 +26,9 @@ add_filter( 'render_block_data', __NAMESPACE__ . '\update_header_template_part_class' ); add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' ); +// Remove Jetpack CSS on frontend +add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 ); + /** * Enqueue scripts and styles. */ @@ -96,6 +100,16 @@ function enqueue_assets() { } } +/** + * Dequeue or deregister some scripts and styles on frontend for performance. + */ +function maybe_dequeue_assets() { + if ( ! is_user_logged_in() && is_front_page() ) { + wp_deregister_style( 'dashicons' ); + wp_deregister_style( 'wp-mediaelement' ); + } +} + /** * Load the shortcodes available for the theme. */