-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
What problem does this address?
Related WordPress Trac ticket: https://core.trac.wordpress.org/ticket/48654.
JavaScript Modules
Resource: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
JavaScript has had modules for a long time. However, they were implemented via libraries, not built into the language. ES2015 is the first time that JavaScript has built-in modules. Older browsers like Internet Explorer 11 didn't support ES Modules. Earlier this year, WordPress dropped support for IE11, which opened the door to using ES Modules in the Gutenberg plugin and later in WordPress core. The most significant benefit of moving the codebase to modules is the possibility of using native browser techniques for async loading scripts
Import Maps
Resource: https://wicg.github.io/import-maps/
Import maps allow web pages to control the behavior of JavaScript imports.
There's native support for import maps in the latest versions of Chrome and Edge browsers, and a shim is available for any other browser that WordPress supports. In practical terms, import maps let use shared libraries by importing dependencies through a predefined list of aliases.
What is your proposed solution?
A long-term goal would be to use JavaScript modules and import maps for all Gutenberg plugin scripts. @youknowriad did some very promising initial explorations: