Opened 10 years ago
Closed 13 months ago
#33252 closed feature request (wontfix)
Add a Faster SHORTINIT-like admin-ajax Alternative
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.3 |
Component: | General | Keywords: | |
Focuses: | performance | Cc: |
Description
The existing admin-ajax.php
is slow because it loads the whole Core.
Even though that's useful, this makes admin-ajax.php
slow to use in front-end scenarios where you need fast responses.
Some code snippets exist that circumvent this by creating their own ajax handlers that utilize the SHORTINIT constant. Although these solutions would require you to load wp-load.php
yourself which is not advised. E.g. https://coderwall.com/p/of7y2q/faster-ajax-for-wordpress from 2012
I'd like to propose a feature request for an admin-ajax.php
likehandler that:
- doesn't load the whole core,
- loads only some essential functions similar to the functionality given by SHORTINIT
Implementation suggestion: The best way to implement this in my opinion is to create 2 new action hooks wp_ajax_shortinit_{action}
and wp_ajax_shortinit_nopriv_{action}
that behaves identically with wp_ajax_{action}
and wp_ajax_nopriv_{action}
except that the SHORTINIT-like environment is implemented.
Change History (5)
#3
@
10 years ago
Hi, thanks for the report!
Do you have any benchmarking that describes how long it takes to load Core fully versus SHORTINIT
? Are you using APC? In this SHORTINIT
-like environment, should any WP APIs be available?
You can always hit your own custom endpoint and not load WordPress at all. There are a lot of cross-dependencies in WordPress that are hard to untangle. WordPress loads a LOT of functions which makes it hard to selectively not load some of them.
Related: #26806