Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is a technical doubt I had after reading some articles about WP ajax process (cannot find them though).

Is it faster and cheaper to load WP content (any content, page, post, widgets etc...) using WP ajax API than making a full canonical page request?

I thought about this because maybe passing through wp-admin/admin-ajax.php is lighter than loading a new page running the whole WP stack altogether.

Am I right?

share|improve this question

migrated from meta.wordpress.stackexchange.com Sep 25 '12 at 16:17

This question came from our discussion, support, and feature requests site for WordPress developers and administrators.

1  
thanks @toscho, I noticed there was something strange going on! didn't notice i was in meta :D –  Bakaburg Sep 25 '12 at 16:55

1 Answer 1

No. Let's compare.

Normal load:

  1. Access URL.
  2. Load WP core.
  3. Retrieve stuff from database.
  4. Load template file.

Ajaxy load:

  1. Accesss URL.
  2. Load WP core.
  3. Load template file.
  4. Load JavaScript.
  5. Make Ajax request.
  6. Load WP core (again).
  7. Retrieve stuff from database.
  8. Receive stuff from Ajax.
  9. Put into page.

Repeat steps 5-9 for each Ajax request.

share|improve this answer
    
your list is valid for the first page load and in that situation you got a point. But I was referring to sequential calls using ajax instead of reloading the page, for example for pagination or in web apps (ok, don't take in count the SEO stuff) –  Bakaburg Sep 25 '12 at 17:02
    
I made the same question in stackoverflow and a guy told me that even in the ajax call all the plugins are run again. is that true? –  Bakaburg Sep 25 '12 at 17:04
    
@Bakaburg yes, you can reuse page and change content with Ajax, but you are making heavy trade-offs in complexity of implementation and ease of caching. And yes, a guy was correct - Ajax endpoint does full WP core load, including plugins and themes. Otherwise they wouldn't work with Ajax. –  Rarst Sep 25 '12 at 17:11
    
themes too?? what for? –  Bakaburg Sep 25 '12 at 17:18
    
@Bakaburg how do you suppose theme would use Ajax in WordPress if it won't load when Ajax is executed? :) To elaborate, by themes I mean functions.php files of active parent & child themes (and of course whatever they choose to further load). –  Rarst Sep 25 '12 at 19:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.