Unlayer Examples
Documentation

Custom JS

In this example, we will add confetti to our editor using custom JavaScript. You can visit the documentation for more options.

We'll need to create a custom.js file that includes the JavaScript to add confetti to our editor.

custom.js

function startConfetti() {
  // confetti code goes here...
}

startConfetti();

Then, we'll pass the custom.js URL to the editor in init option customJS.

  • The URL must be absolute
  • You can load multiple URLs by passing more in the array
  • If you don't have the option to pass a URL, you can directly pass your JavaScript code as a string
unlayer.init({
  id: 'editor-container',
  displayMode: 'email',
  customJS: ['https://examples.unlayer.com/examples/custom-js/custom.js'],
});

Preview