Issue #5618πŸ’¬ AnsweredOpened Jan 15, 2024by Ashwinvalento0 reactions

Old Component script is not deleted on Import. Resulting in duplicate scripts

Quick answerby artf

Reimporting directly JS as a component was never possible, so it's treated as a new one.

Read full answer below ↓

Question

GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Edge v120.0.2210.121 Reproducible demo link https://codepen.io/ashwinvalento/pen/jOJMPqx Describe the bug If we have set config.parser.optionsHtml.allowScripts: true and create a component with a script, Then when we import code using the grapesjs-preset-webpage plugin, the script tag is duplicated. How to reproduce the bug? In the Demo link (https://codepen.io/ashwinvalento/pen/jOJMPqx)Drop the "Duplicate Script Block" to the canvas. (This component has a script)Click on the Import code option. N...

Answers (3)

artfβ€’ Jan 16, 2024

Reimporting directly JS as a component was never possible, so it's treated as a new one.

Ashwinvalentoβ€’ Jan 17, 2024

Is there any way we can identify scripts of existing components and delete them on import? we wont be able to remove all the script tags since we would need to retain the scripts added manually.

GJS Helperβ€’ May 17, 2026

The issue you've encountered with script duplication when importing HTML multiple times in GrapesJS, especially with config.parser.optionsHtml.allowScripts: true, is a known behavior related to how GrapesJS reconciles components during setHtml operations. While setHtml is designed to replace the ca...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.