Skip to content

Commit

Permalink
Merge pull request #237 from WordPress/fix/233-performance
Browse files Browse the repository at this point in the history
Remove unnecessary blocking style requests
  • Loading branch information
adamwoodnz authored Oct 11, 2023
2 parents c8b5321 + 2167efc commit 787ce24
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/wp-content/themes/wporg-showcase-2022/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

// Filters and Actions
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' );
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\maybe_dequeue_assets' );
add_action( 'init', __NAMESPACE__ . '\setup_theme' );
add_action( 'wp_head', __NAMESPACE__ . '\add_social_meta_tags' );
add_action( 'pre_get_posts', __NAMESPACE__ . '\modify_search_query' );
Expand All @@ -39,6 +40,8 @@
add_filter( 'grunion_should_send_email', '__return_false' );
// Enable auto-fill using user information.
add_filter( 'jetpack_auto_fill_logged_in_user', '__return_true' );
// Remove Jetpack CSS on frontend
add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 );

/**
* Enqueue scripts and styles.
Expand All @@ -56,6 +59,15 @@ function enqueue_assets() {
wp_style_add_data( 'wporg-showcase-2022-style', 'rtl', 'replace' );
}

/**
* Dequeue or deregister some scripts and styles on frontend for performance.
*/
function maybe_dequeue_assets() {
if ( ! is_user_logged_in() ) {
wp_deregister_style( 'dashicons' );
}
}

/**
* Register theme support.
*/
Expand Down

0 comments on commit 787ce24

Please sign in to comment.