Reputation: 3321
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?
Thanks
Upvotes: 0
Views: 1796
Reputation: 19888
I say it all depends on how much processing is going on in your wordpress page. If your widgets take a long time to process because they are making soap/external api calls then it would be in your best interest to load those widgets via ajax. Loading them via ajax will make your page load faster which looks better to google. If they all load pretty quickly then ajaxing the page will just put more stress on your db and webserver since it will take more traffic to deliver a single page.
Also, I would only use ajax for areas on the page that you'd like to change without doing a reload of the page, such as commenting or a data stream.
Upvotes: 1
Reputation: 10595
Yes it typically is.
Bit I've hit situations where the Wordpress Ajax api is slow:
https://wordpress.stackexchange.com/questions/41808/ajax-takes-10x-as-long-as-it-should-could
So if you are hitting a bug or issue with the Wordpress ajax api... it might be slower.
But that's not Ajax's fault. Ajax itself is way faster.
Ajax is usually faster because it avoids reloading the entire page for minor changes. This is a huge win, especially for things like commenting on a huge article. You can imagine if you have to re-load the article after each comment, ouch. Ajax avoids that.
Upvotes: 1