Our JavaScript SDK exposes methods that enable the app to communicate with the Wix platform – the Editor, Dashboard, live site, and preview.
Include the following script tag in your HTML document:
Once included, your window object will contain a new global Object named Wix.
We release new versions of our JavaScript SDK regularly. Update your app to use the latest version by replacing the version number in the script tag.
Note the following:
In 2015, we launched a new and improved version of the Wix Editor. We are gradually moving users over to the new Editor, so some users are still using the old Editor.
All methods that are available since SDK version 1.45.0 are not supported in the old Editor. To use these methods, you’ll need to detect the user’s Editor version and add a fallback option for the old Editor.
Here’s how:
The Wix global object can be used in all components’ endpoints – Widget, Page, Fixed Position, Dashboard, Worker, and App Settings – as well as its controls – Modal and Popup. However, some of its functions make sense only in certain endpoints.
The most obvious distinction is the App Settings endpoint.
The App Settings endpoint is different since it is the only endpoint that resides in the Editor while the others reside in the user’s website or the My sites dashboard. For that reason we created a namespace Wix.Settings that holds all the functions that are valid in the App Settings endpoint.
Another special namespace is the Wix.Utils. It provides utility functions that can be called by all endpoints (except worker).
Note:
Although Wix.Utils is valid for all endpoints (except worker), if the called function doesn’t have a meaningful value to return, it returns null. For example, when Wix.Utils.getOrigCompId() is used in the App Settings endpoint, the function returns the component ID that called it – but for other endpoints, it returns null.
{note}
If you see a method in our SDK has a callback function, this means that the method is asynchronous. The “return” value is passed as an argument in the callback function.