WordPress JavaScript

WordPress has long worked with JavaScript but with the advent of Gutenberg we are seeing a new era of JavaScript development, especially with the use of React. This page will be split into four main sections:

  • Vanilla JS – Historically this was used for small snippets of code, now it has become more common to use Modern JS (ES6+).
  • Ajax – WP handles AJAX in its own way historically. This is often implemented in jQuery, but we’ll deal with it here separately as it is such an important topic.
  • jQuery JS (and others) – jQuery was the preferred library in WP for many years and is still widely used. In addition there are other libraries such as Backbone.js that have played an important role in WP historically but whose usage has declined.
  • Gutenberg JS – This crosses paths with Vanilla JS of the modern flavor but here I’m thinking more specifically of its connections to the React ecosystem and Gutenberg’s abstraction layer on top of React.

Note that these divisions aren’t nice and neat, so browse through the other sections and you’ll likely find some series/articles which have crossover.

Vanilla JavaScript


jQuery (and others)