Switching pages calls canvas styles and scripts again and again
Question
Hi
I am integrating page manager into my project. But the issue I am facing is that whenever I switch between pages it loads CSS and script files given in canvas object at the time of init, again and again.
It makes the switching between pages slow.
Implementation:
grapesjs.init({ pageManager: { pages: [ { id: 'Page-1', styles: ``, // or a JSON of styles component: '', // or a JSON of components name: 'Page 1', }, ], },
canvas: {
styles: [
'../assets/bootstrap/bootstrap.min.css',
'../assets/platforma/platforma.min.css',
'../assets/editor.css',
],
scripts: [
'../assets/bootstrap/jquery-3.5.1.slim.min.js',
'../assets/bootstrap/bootstrap.bundle.min.js',
'../assets/platforma/platforma.bundle.min.js',
],
},
})
after that, I am adding pages manually on click of a button
Answers (3)
@artf Can you please help?
Unfortunately, switching pages creates a new iframe so, the behavior is correct. I preferred to remove previous iframes in order to keep the memory usage as low as possible. One solution might be to find a way to reuse previous iframes but that might cause context issues with external JS... so I'm not sure how to properly prevent this behavior. Anyway, to be honest I'd not expect switching so slow after the first load as external files should be cached by the browser... are you able to create a screencast of your experience?
Thanks for reporting this, @chiragkataria22.
Thanks for sharing your report about Switching pages calls canvas styles and scripts again and again. To help the team investigate and prioritize this:
Please provide:
- A minimal reproducible example (CodeSandbox/JSFiddle)
- Your GrapesJS version number
- Browser and OS information
- Any error messages from the browser console
- Steps to reproduce the issue
What helps most:
- Minimal code example (not your full project)
- Screen recording or screenshot showing the issue
- Expected vs actual behavior clearly stated
- GrapesJS configuration you're using
With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3699
Cell hovering randomly displaces from actual cell
Hi! I'm using grapesJs for e-mail editing in a project in my company, with Newsletter plugin. Everithing works very well, except for this b...
Issue #3223
FEAT: Create the canvas from a URL
I've been playing with GrapesJS and trying to integrate it into a Symfony 5 project. In particular I want to be able to edit templates in t...
Issue #3627
[QUESTION]: I'm trying to duplicate the page, but the styles are not geting applied due to the Ids, changes to -2,-3 at the end.
This is what my function looks like. I am trying duplicate the page, the HTML part is fine but as css is applied through ids, when a new pa...
Issue #4796
Custom Traits not Updating if using mjml
This Method Works Fine for Normal HTML. But When I Tried With MJML For MJ-IMAGE Tag The Src is Updated in TR Tag but not updated in img tag...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins βPremium plugins ship with support, regular updates, and production-ready features β save days of integration work.
Browse premium plugins βBrowse Plugin Categories
Jump directly to plugin category pages on the marketplace.