Skip to main content

Preventing JavaScript Execution Inside the Editor

If you want to block users from running any JavaScript code inside the editor or within the HTML tool, you can enable Unlayer’s built-in Safe HTML mode.

Khizar Tanveer avatar
Written by Khizar Tanveer
Updated over 3 months ago

How to Enable Safe HTML

Add the safeHtml property to your unlayer.init() configuration:

unlayer.init({
safeHtml: true
});

Once enabled, the editor will automatically sanitize any HTML content added by end-users, removing all JavaScript or unsafe attributes.

When to Use Safe HTML

  • When allowing end-users to edit or insert custom HTML.

  • In public-facing or multi-tenant applications.

  • To prevent accidental or intentional injection of malicious code.

Did this answer your question?