Skip to:

conditional bp header items

  • Windhamdavid


    using Buddypress as a minor feature in a project and I’m tinkering with the page load times and overall code aesthetics… thinking I want to only load the core and widget (.js/css) files (enqueue_script() in bp-core-cssjs.php) to the head for certain template pages? still dependent on bp for other pages, don’t want to hack the core, don’t want to do it on a template level with wp_head. i searched the mu and wp forums to see if it’s been done for another plugin… has anyone done/seen anything similar and wanna get me started this morning?

Viewing 2 replies - 1 through 2 (of 2 total)

  • r-a-y


    I’ve been thinking of doing this.

    Will investigate and report back.


    Here’s one way of doing what you want to do.

    I’ve made it so that the main WP theme will not load the core BP CSS/JS files.

    But on BP pages, it will load them.

    Enter this only on your WP theme’s functions.php:

    function remove_bp_cssjs() {
    remove_action('wp', 'bp_core_add_js');
    add_action('init', 'remove_bp_cssjs');

    Caveats with this approach is you’ll need to load the bp_core_add_js() function again manually if you use any BP widget on any WP post or page.

    A way to do this is to manually add the BP CSS styles to your main WP theme’s stylesheet, while using Justin Tadlock’s Javascript Logic plugin to load the BP javascripts on a conditional basis. I’ll let you figure that one out ;)

    I’m also looking at trimming more of the BP fat by removing the widget CSS files that are left over as well.

    Stay tuned…



    Hmm… not sure how to remove the widget JS/CSS that use wp_enqueue_script and wp_enqueue_style.

    If anyone has any pointers for this without hacking the core, let me know.

    Also, I’d just like to say to the BP devs that instead of separating each CSS/JS file into separate components, why not load all BP javascripts in one file?

    Same goes for the widget CSS files. (I understand the BP CSS is a little too much to jam into one file… with all the different structure.css files!)

    This would help reduce the number of server requests and also keep the HTML source a little bit leaner.

    Just a thought.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘conditional bp header items’ is closed to new replies.
Skip to toolbar