Skip to:
Content

BuddyPress.org

Opened 23 months ago

Closed 13 months ago

Last modified 2 months ago

#8679 closed task (fixed)

Only load template pack JS & CSS assets when needed

Reported by: imath's profile imath Owned by: imath's profile imath
Milestone: 12.0.0 Priority: high
Severity: normal Version:
Component: Templates Keywords: has-patch
Cc:

Description

Currently these assets are loaded everywhere. These should only be loaded when true === is_buddypress().

Attachments (2)

8679.patch (6.7 KB) - added by imath 21 months ago.
8679.2.patch (7.1 KB) - added by imath 20 months ago.

Download all attachments as: .zip

Change History (13)

@imath
21 months ago

#1 @imath
21 months ago

  • Keywords has-patch needs-testing added; needs-patch removed

The above path is introducing the bp_enqueue_community_scripts action hook which is only fired when is_buddypress(). It seems to be enough.. But I believe it needs more testing especially with legacy widgets...

Version 0, edited 21 months ago by imath (next)

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


20 months ago

@imath
20 months ago

#3 @imath
20 months ago

  • Keywords 2nd-opinion added; needs-testing removed

To follow up with the discussion we had during July 6 dev-chat, I've updated the patch to introduce a new filter bp_enqueue_assets_in_bp_pages_only (instead of a constant) we can use to customize how BuddyPress assets are loaded according to 2 options:

  1. everywhere (return false to the filter).
  2. only in is_buddypress() areas (return true to the filter).

For 11.0.0 the default value will be false: we'll carry on loading BP Assets everywhere. This way we take no risks with BP Plugins which might need these assets everywhere while we let people wishing to contribute to BuddyPress use add_filter( 'bp_enqueue_assets_in_bp_pages_only', '__return_true' ); to restrict BP assets to BP areas only. We'll be able to see if these contributors warn us about broken things (I suspect mainly in BP Legacy widgets).

Before releasing 12.0.0, we'll be able to change our default value to true considering BP Plugins authors had time to check their plugins.

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


20 months ago

#5 @imath
19 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 13306:

First step towards only loading Template Packs assets in BP pages

Avoid loading these assets everywhere inside the blog is a frequent request made by BuddyPress users. In 11.0.0 we are doing a first step into this direction by making available a new filter to restrict Template Packs assets loading to BuddyPress pages.

We encourage these users to simply add the add_filter( 'bp_enqueue_assets_in_bp_pages_only', '__return_true' ); code into a BP Custom file for instance to contribute to testing whether it has an unwanted side effect on the BuddyPress plugins that they might have activated.

This will help us feel more secure about completely restricting these assets to BP pages in a second step.

Props dcavins

Fixes #8679

This ticket was mentioned in Slack in #buddypress by imath. View the logs.


16 months ago

#7 @imath
13 months ago

  • Keywords needs-patch added; has-patch 2nd-opinion removed
  • Milestone changed from 11.0.0 to 12.0.0
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Type changed from defect (bug) to task

It's time to move the other way around!

Let's change our default value to true considering BP Plugins authors had time to check their plugins.

This ticket was mentioned in PR #64 on buddypress/buddypress by @imath.


13 months ago
#8

  • Keywords has-patch added; needs-patch removed

#9 @imath
13 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 13418:

Second step towards only loading Template Packs assets in BP pages

In 11.0.0 we made a first step into this direction by making available a
filter to restrict Template Packs assets loading to BuddyPress pages. By
default this filter was returning false to carry on loading assets.

In 12.0.0 we are changing this default value to true so that we are now
only loading Template Packs assets in BP Pages. If you need to keep these
assets being loaded everywhere on your site, you'll have to hook to this
filter & return false.

Eg: `add_filter( 'bp_enqueue_assets_in_bp_pages_only', 'return_false'
);`

Props dcavins

Closes https://github.com/buddypress/buddypress/pull/64
Fixes #8679

#10 @imath
2 months ago

In 13672:

BP Template packs: only add the no-js body class in community area

Since [13418] we do not load community assets by default everywhere on the site anymore.

But this commit appears to be incomplete: we also need to avoid adding the no-js body class when not in a community area.

NB: returning false to the 'bp_enqueue_assets_in_bp_pages_only' filter will carry on loading BP Template pack assets everywhere on the site.

Props sabernhardt, emaralive, shawfactor

See #8679
See #9033 (trunk)
Closes https://github.com/buddypress/buddypress/pull/201

#11 @imath
2 months ago

In 13673:

BP Template packs: only add the no-js body class in community area

Since [13418] we do not load community assets by default everywhere on the site anymore.

But this commit appears to be incomplete: we also need to avoid adding the no-js body class when not in a community area.

NB: returning false to the 'bp_enqueue_assets_in_bp_pages_only' filter will carry on loading BP Template pack assets everywhere on the site.

Props sabernhardt, emaralive, shawfactor

See #8679
Fixes #9033 (branch 12.0)

Note: See TracTickets for help on using tickets.