[buddypress-trac] [BuddyPress Trac] #7549: Only load AJAX code on AJAX requests

buddypress-trac noreply at wordpress.org
Thu Jun 22 00:27:48 UTC 2017


#7549: Only load AJAX code on AJAX requests
-------------------------+------------------
 Reporter:  r-a-y        |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  3.0
Component:  Core         |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+------------------

Comment (by r-a-y):

 You should be most concerned about #7549 and not this one.  #7549 will
 autoload the component action and screen code.

 However, for this ticket, I only want to load AJAX when absolutely
 necessary since AJAX code has no usage outside of AJAX requests.

 Something like this:

 {{{#!php
 <?php
 add_action( 'bp_include', function() {
         // AJAX condition.
         if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX ) {
                 // This file would contain any function hooked to
 'wp_ajax_{WHATEVER}'
                 require 'ajax.php';
         }
 } );
 }}}

 Can you give me a use-case where this would be a problem?  Would you call
 an AJAX function on the frontend?  I'm not sure why anyone would do that.

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


More information about the buddypress-trac mailing list