WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I noticed while looking at the HTML of an edit page that WordPress uses a lot of hidden input elements for storing nonces. Is there a significant advantage to using either this style of storing nonces for AJAX use or using those stored via the wp_localize_script style?

share|improve this question
up vote 1 down vote accepted

Depends, will the form work with AJAX turned off?

If so use an input and degrade gracefully.

Otherwise, define nonces used by JS using JS for consistency, and to prevent grabbing stuff from the DOM

share|improve this answer

Input fields are sent automatically, even when JavaScript is turned off. You can easily grab their values per JavaScript for AJAX requests, so there is no benefit coding them as JS object.

share|improve this answer

Your Answer


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.