When you are running a high-traffic site, even cutdown 1-2 extra seconds in site load time are gold. With the installation of several WordPress Plugins which help improve your site function and development, bulk styles and js loading could take more extra seconds from your site load speed.

Today, in particular, I will show you how to disable BBPress, BBPress Post Toolbar, and BBPress GD Attachments plugin’s styles and javascript on another page except for the associated ‘forums’ page.

1. Disable BBPress default template CSS stylesheet

You can add this to your functions.php, preferably at bottom of the PHP file before the end ?>

[php]function mp_deregister_bbstyles() {
if ( function_exists( ‘is_bbpress’ ) ) {
if ( !is_bbpress() ) {
wp_deregister_style( ‘bbp-default-bbpress’ );
}
}
}
add_action( ‘wp_print_styles’, ‘mp_deregister_bbstyles’, 100 );[/php]

2. Disable BBPress Post Toolbar CSS stylesheet and JS Scripts

You can add this to your functions.php, preferably at bottom of the PHP file before the end ?>

[php]function mp_deregister_bbptstyles() {
if ( function_exists( ‘is_bbpress’ ) ) {
if ( !is_bbpress() ) {
wp_deregister_style( ‘bbp_5o1_post_toolbar_style’ );
wp_deregister_style( ‘bbp_5o1_post_toolbar_uploader_style’ );
}
}
}

function mp_deregister_bbptscript() {
if ( function_exists( ‘is_bbpress’ ) ) {
if ( !is_bbpress() ) {
wp_deregister_script( ‘bbp_5o1_post_toolbar_script’ );
wp_deregister_script( ‘bbp_5o1_post_toolbar_uploader_script’ );
}
}
}
add_action( ‘wp_print_styles’, ‘mp_deregister_bbptstyles’, 100 );
add_action( ‘wp_print_scripts’, ‘mp_deregister_bbptscript’, 100 );[/php]

3. Disable BBPress GD Attachment CSS stylesheet and JS Scripts

You can add this to your functions.php, preferably at bottom of the PHP file before the end ?>

[php]function mp_deregister_bbgdstyles() {
if ( function_exists( ‘is_bbpress’ ) ) {
if ( !is_bbpress() ) {
wp_deregister_style( ‘d4p-bbattachments-css’ );
}
}
}

function mp_deregister_bbgdscript() {
if ( function_exists( ‘is_bbpress’ ) ) {
if ( !is_bbpress() ) {
wp_deregister_script( ‘d4p-bbattachments-js’ );
}
}
}

add_action( ‘wp_print_styles’, ‘mp_deregister_bbgdstyles’, 100 );
add_action( ‘wp_print_scripts’, ‘mp_deregister_bbgdscript’, 100 );[/php]

Final Conclusion

You might wonder what’s the difference the above code can bring to your site load speed. Well before added the above code, using Pingdom Test the site load time are about 6.75s and 7.28s with 228 Requests ( tested 2 times ). As you can see, after added the code, the site load time is significantly decreased to 1.97s only and Requests are down to 217, 11 requests from BBPress and BBPress plugins were excluded.

magpress-pingdom-test-bench

A standard site load time below 3s is optimal for me, hopefully, I can find a way to reduce page size to below 1MB at least. Using a CDN service seems like the right track.

Hope you enjoy the read, more BBPress Tips, and Tricks coming this month.