Search page enqueueing assets

When doing a search on our sites, it looks like the search-results CSS and JS files are included on the search page. Is this supposed to happen or is this a bug?

Hey Josh,

I just tried playing around on my local dev but I can’t seem to see the CSS and/or JS files? Do you think you can share the URL of the site where this is happening and possibly list down the steps to recreate the issue?

Ben

It seems to enqueue the assets for custom post types, I’ll include some examples in the next post.

[Content Hidden]

Gotcha! You can check the KB article below for a way to remove those. For your case, you can use if ( is_search() ).
http://forum.wpbeaverbuilder.com/knowledge-base/prevent-cssjs-from-loading-on-archive-pages/

Ben

Thanks Ben. is_search didn’t seem to work so I ended up using the pre_get_posts filter instead:


function hide_bb_assets($query){
  if ( $query->is_search() ) {
    remove_action( 'wp_enqueue_scripts', 'FLBuilder::layout_styles_scripts' );
  }
}

add_filter('pre_get_posts','hide_bb_assets');

Hey Josh,

Thanks for sharing! Have fun with BB! :slight_smile:

Ben