Skip to:
Content

Opened 17 months ago

Closed 7 months ago

#5208 closed defect (bug) (fixed)

enqueues buddypress.js

Reported by: bassjobsen Owned by:
Milestone: 2.1 Priority: normal
Severity: normal Version: 1.8.1
Component: Component - Core Keywords:
Cc: valuser@…

Description

in bp-templates/buddypress-legacy/buddypress-functions.php the function enqueue_scripts() enqueues buddypress.js. buddypress.js not only depends on jquery but also on jquery-cookie.
Set the $deps Array of the handles in the wp_enqueue_script() call to array('jquery','jquery-cookie') will fix this.

Thanks for your attention. I will need this fixes to get WP Defer Loading work with BuddyPress, see: https://github.com/bassjobsen/wp-defer-loading/issues/4

Attachments (1)

create-minified-scripts.patch (6.3 KB) - added by dcavins 9 months ago.

Download all attachments as: .zip

Change History (16)

comment:1 @boonebgorges17 months ago

We don't enqueue based on jquery.cookie because the plugin is shipped inline in buddypress.js. So it's not technically a dependency, at least not in the sense that wp_enqueue_script() understands dependencies.

Can you explain the sorts of problems that are being caused by the current setup?

comment:2 @bassjobsen17 months ago

Hello,

Thanks for your response. I have to say, sorry cause i made a mistake my fix seems not to load buddypress.js at all (which fix my error, but broke other things).

I still got a problem with buddypress.js and it's inline cookie and other plugins.

Cause i load the script deferred the document ready already fired (or better happened).
So the document ready functions are fired after reading. The plugins are at the end of the source and not read (exist) when the functions run.

So maybe this not a bug but a request.
You will help my plugin function when moving the plugin to the start of the source. Something like:

{{{/* jQuery Easing Plugin, v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ */
jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend...
/* jQuery Cookie plugin */
jQuery.cookie=function(name,value,options)...
/* ScrollTo plugin - just inline and minified */
;(function($){var h=$.scrollTo=function(a,b,c)...
/* jQuery querystring plugin */
eval(function(p,a,c,k,e,d){e=function(c)....

var jq = jQuery;

Global variable to prevent multiple AJAX requests
var bp_ajax_request = null;
AJAX Functions
jq(document).ready( function() {

/ Page Load Actions */}}}

comment:3 @boonebgorges16 months ago

I guess my preference, rather than doing that, would be to put the plugins into separate files and then enqueue them properly. Do any other devs have opinions about this?

comment:4 @DJPaul16 months ago

I don't think we want to do this for 1.9. Perhaps 2.0, or whenever the updated theme templates are ready.

comment:5 @bassjobsen16 months ago

@boonebgorges i also think enqueue them properly will be the best solution.
@DJPaul what about move the plugin to the begin / start of the source?

comment:6 @boonebgorges16 months ago

  • Milestone changed from Awaiting Review to 2.0

Let's do a proper fix for 2.0. We will not necessarily be able to cut the inline plugins out of our plugins altogether - that'd break child themes, etc that enqueue our assets directly from the BP folder, and won't change the dependencies - but we can do some sort of conditional thing.

comment:7 @boonebgorges11 months ago

  • Milestone changed from 2.0 to 2.1

comment:8 @johnjamesjacoby9 months ago

In 8453:

First pass at unbundling inline jQuery plugins from BP Legacy's buddypress.js and BP Default's global.js. See #5208.

comment:9 @johnjamesjacoby9 months ago

r8453 accidentally included the buddypress.pot file. Drat.

Also, it somewhat throws back-compat out the window with replacing the obfuscated and slow jQuery Query plugin, that I honestly could not actually find in the wild anywhere on the internet anymore.

One approach to fixing this would be to write a jQuery.query.get plugin equivalent, but I guess I'm willing to gamble that anyone that copied our old global.js did so completely, will have the inline plugins too, and won't have any problems with the new JS approach.

Needs testing, but I was looking at this code for the past few days and was itchy to get it in early.

comment:10 follow-up: @johnjamesjacoby9 months ago

Related: #1673.

comment:11 in reply to: ↑ 10 @dcavins9 months ago

Replying to johnjamesjacoby:

Related: #1673.

After updating my test installation fro the GitHub repo, I was getting errors because the minified js files hadn't yet been included.

The script loading is working for me now, though.

comment:12 @valuser9 months ago

  • Cc valuser@… added

Was following the track on local installs.
Had a problem with this revision - with a slider plugin (premium - Slider Pro).
Basically the plugin stopped working at this revision with just it and buddypress and theme TwentyTwelve/Twenty Fourteen Theme installed.
Not competent to even suggest anything.
Sent the attachment on this comment to the plugin developer & hopefully he will take it up from there.

valuser

comment:13 @valuser9 months ago

Have added those 5 javascript files (per dcavins patch above) to bp-core/js ---- no joy

comment:14 @valuser9 months ago

Once again I must admit to and apologise for a false alarm.
Please disregard my previous contributions (comments 12,13) on this ticket.

comment:15 @DJPaul7 months ago

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

Discounting the previous few tickets, I think this is done now, so I'm closing the ticket.

Note: See TracTickets for help on using tickets.