Wix supports working in JavaScript to develop websites, as well as some special features, including:
You can work in JavaScript in:
Wix supports modern JavaScript features up through and including the ES2020 standard.
You can use promises, async/await, and arrow functions, which were introduced with ES2017.
Browsers are gradually adopting the ES2019 standard. Until these standards are fully implemented, we transpile your code into ES5, so it can run in current browsers. Wix supports source maps, so that even though the browser runs transpiled ES5 code, you can debug your ES2019 source code in your browser's developer tools.
Wix supports the native module functionality included in the ES2015 release of JavaScript.
To use ES2015 module functionality, you need to follow the ES2015 Module Syntax. Only those items specifically exported in a module are exposed to other files. All other items in your module are internal to the module only.
For examples of how to use this functionality, see MDN's JavaScript modules guide.
Notes:
events.js
, data.js
, or routers.js
files. For more information, see Module Export Syntax for Backend Events, Data Hooks, and Routers.The following is a list of guidelines that define how you can share modules and functions between, and within, the backend and public scopes:
Wix Fetch is an implementation of the standard JavaScript Fetch API, and you work with it the same way, using standard Fetch syntax. You can look at examples of using Fetch, or check out the Standard Fetch specification.
Use Wix Fetch rather than the standard JavaScript Fetch API whenever you need an http/s
request. You can use Wix Fetch in both backend and frontend code. To use Wix Fetch in your JavaScript code, add import {fetch} from 'wix-fetch'
to the beginning of your JavaScript file.
Among its benefits, Wix Fetch uses promises to handle asynchronous requests, which allows for easier handling of results and errors.