admin-ajax.php vs Custom Page Template for Ajax Requests

First, the obvious drawback to the first method is that it depends on your specific page, template, and permalink structure to all work correctly. Using admin-ajax.php will work correctly in any context, theme or plugin, where proper WordPress best practices are followed.

The less obvious drawback to the first method is that it uses more memory than doing WordPress-enabled AJAX calls, since the whole WordPress environment is loaded, as it’s presumed that a front-end or admin page will be output.

The addition of NONCEs with admin-ajax.php provides easy, built-in security.

Leave a Comment