Issue #5441πŸ’¬ AnsweredOpened Oct 3, 2023by padcom0 reactions

No id for elements not having styles but with `script`, which results in script not running for those elements

Quick answerby artf

The issue is caused by the use of jsInHtml: false and how the internal JS generator is handled. I'll try to fix it for the next release.

Read full answer below ↓

Question

GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome latestReproducible demo link https://github.com/padcom/grapesjs-no-id-for-element-exampleDescribe the bug When creating custom GrapesJS components, if those components have the script() (runtime behavior for component) and no styles are being applied to that component then the root element doesn't have the id attribute which then fails the document.querySelectorAll('#<id-goes-here') and the runtime script is not called. In the given example, I have created a special custom element, called <co...

Answers (2)

artfβ€’ Oct 8, 2023

The issue is caused by the use of jsInHtml: false and how the internal JS generator is handled. I'll try to fix it for the next release.

GJS Helperβ€’ May 17, 2026

The issue you've described is a known behavior in GrapesJS related to how component IDs are generated and optimized during HTML serialization. When a custom component has a script() function but no explicit styles applied to it, GrapesJS might omit the id attribute from the component's root element...

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.