Scripts
Edit
The editor provides several vendor and internal scripts to plugin developers. Script names, handles, and descriptions are documented in the table below.
WP Scripts WP Scripts
The editor includes a number of packages to enable various pieces of functionality. Plugin developers can utilize them to create blocks, editor plugins, or generic plugins.
Script Name | Handle | Description |
---|---|---|
Blob | wp-blob | Blob utilities |
Block Library | wp-block-library | Block library for the editor |
Blocks | wp-blocks | Block creations |
Block Serialization Default Parser | wp-block-serialization-default-parser | Default block serialization parser implementations for WordPress documents |
Block Serialization Spec Parser | wp-block-serialization-spec-parser | Grammar file (grammar.pegjs) for WordPress posts |
Components | wp-components | Generic components to be used for creating common UI elements |
Compose | wp-compose | Collection of handy Higher Order Components (HOCs) |
Core Data | wp-core-data | Simplify access to and manipulation of core WordPress entities |
Data | wp-data | Data module serves as a hub to manage application state for both plugins and WordPress itself |
Date | wp-date | Date module for WordPress |
Deprecated | wp-deprecated | Utility to log a message to notify developers about a deprecated feature |
Dom | wp-dom | DOM utilities module for WordPress |
Dom Ready | wp-dom-ready | Execute callback after the DOM is loaded |
Editor | wp-editor | Building blocks for WordPress editors |
Edit Post | wp-edit-post | Edit Post Module for WordPress |
Element | wp-element | Element is, quite simply, an abstraction layer atop React |
Escape Html | wp-escape-html | Escape HTML utils |
Hooks | wp-hooks | A lightweight and efficient EventManager for JavaScript |
Html Entities | wp-html-entities | HTML entity utilities for WordPress |
I18N | wp-i18n | Internationalization utilities for client-side localization |
Is Shallow Equal | wp-is-shallow-equal | A function for performing a shallow comparison between two objects or arrays |
Keycodes | wp-keycodes | Keycodes utilities for WordPress, used to check the key pressed in events like onKeyDown |
List Reusable blocks | wp-list-reusable-blocks | Package used to add import/export links to the listing page of the reusable blocks |
NUX | wp-nux | Components, and wp.data methods useful for onboarding a new user to the WordPress admin interface |
Plugins | wp-plugins | Plugins module for WordPress |
Redux Routine | wp-redux-routine | Redux middleware for generator coroutines |
Rich Text | wp-rich-text | Helper functions to convert HTML or a DOM tree into a rich text value and back |
Shortcode | wp-shortcode | Shortcode module for WordPress |
Token List | wp-token-list | Constructable, plain JavaScript DOMTokenList implementation, supporting non-browser runtimes |
URL | wp-url | A collection of utilities to manipulate URLs |
Viewport | wp-viewport | Module for responding to changes in the browser viewport size |
Wordcount | wp-wordcount | WordPress word count utility |
Vendor Scripts Vendor Scripts
The editor also uses some popular third-party packages and scripts. Plugin developers can use these scripts as well without bundling them in their code (and increasing file sizes).
Script Name | Handle | Description |
---|---|---|
React | react | React is a JavaScript library for building user interfaces |
React Dom | react-dom | Serves as the entry point to the DOM and server renderers for React, intended to be paired with React |
Moment | moment | Parse, validate, manipulate, and display dates and times in JavaScript |
Lodash | lodash | Lodash is a JavaScript library which provides utility functions for common programming tasks |
Polyfill Scripts Polyfill Scripts
The editor also provides polyfills for certain features that may not be available in all modern browsers.
It is recommended to use the main wp-polyfill
script handle which takes care of loading all the below mentioned polyfills.
Script Name | Handle | Description |
---|---|---|
Babel Polyfill | wp-polyfill | Emulate a full ES2015+ environment. Main script to load all the below mentioned additional polyfills |
Fetch Polyfill | wp-polyfill-fetch | Polyfill that implements a subset of the standard Fetch specification |
Promise Polyfill | wp-polyfill-promise | Lightweight ES6 Promise polyfill for the browser and node |
Formdata Polyfill | wp-polyfill-formdata | Polyfill conditionally replaces the native implementation |
Node Contains Polyfill | wp-polyfill-node-contains | Polyfill for Node.contains |
Element Closest Polyfill | wp-polyfill-element-closest | Return the closest element matching a selector up the DOM tree |
Bundling and code sharing Bundling and code sharing
When using a JavaScript bundler like webpack, the scripts mentioned here
can be excluded from the bundle and provided by WordPress in the form of script dependencies [(see
wp_enqueue_script
)][https://developer.wordpress.org/reference/functions/wp_enqueue_script/#default-scripts-included-and-registered-by-wordpress].
The
@wordpress/dependency-extraction-webpack-plugin
provides a webpack plugin to help extract WordPress dependencies from bundles. @wordpress/scripts
build
script includes
the plugin by default.