Skip to main content

Use ECMAScript 6+ in your theme


Make ECMAScript 6+ code work.

To prevent having cross-browser JavaScript problems, SXA comes with an ES watcher. This way, developers can use ECMAScript 6+ in their code, and also make it work in older browsers. ECMAScript 6+ code in the sources folder is automatically converted file to a file in the scripts folder to offer fallback functionality in older browsers.

To add an ECMAScript 6+ script class:

  1. Store ECMAScript 6+  code in the sources folder of your theme: Media Library/MyTheme/sources

    Add an ECMAScript 6+ class.
  2. Start the default gulp task. The ES watcher now ensures that any ECMAScript 6+ code in the source folder are transformed to JavaScript code and saved in the scripts folder.

    ECMAScript code saved as JS code in the scripts folder.