[buddypress-trac] [BuddyPress Trac] #8679: Only load template pack JS & CSS assets when needed

buddypress-trac noreply at wordpress.org
Thu Jul 4 04:39:21 UTC 2024


#8679: Only load template pack JS & CSS assets when needed
-----------------------+---------------------
 Reporter:  imath      |       Owner:  imath
     Type:  task       |      Status:  closed
 Priority:  high       |   Milestone:  12.0.0
Component:  Templates  |     Version:
 Severity:  normal     |  Resolution:  fixed
 Keywords:  has-patch  |
-----------------------+---------------------

Comment (by michaelsgre):

 The BuddyPress development team has implemented changes to how template
 pack JavaScript and CSS assets are loaded to improve site performance and
 flexibility. Initially, these assets were loaded across the entire site,
 but now they are conditionally loaded based on whether a page is a
 BuddyPress page (is_buddypress()).

 Details:
 Initial Implementation and Concerns:

 Initially, BuddyPress assets were loaded universally, causing performance
 concerns.
 A patch was introduced to load assets conditionally using
 bp_enqueue_community_scripts, only firing when is_buddypress() returned
 true. This required extensive testing, particularly with legacy widgets.
 Development Discussions and Modifications:

 Following community feedback and development discussions, a filter
 bp_enqueue_assets_in_bp_pages_only was introduced.
 The filter allows customization: assets can be loaded everywhere (return
 false) or only on BuddyPress pages (return true).
 For BuddyPress 11.0.0, the default was set to false to minimize risks to
 existing plugins.
 By BuddyPress 12.0.0, the default was changed to true, aligning with the
 goal of loading assets only on BuddyPress pages, while providing a filter
 for flexibility.
 Final Implementation and Further Refinements:

 In BuddyPress 12.0.0, the default was changed to load assets only on
 BuddyPress pages, encouraging plugin authors to adjust their code if
 necessary.
 Additional commits refined this behavior, ensuring elements like the no-js
 body class were also conditionally added.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8679#comment:12>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list