BUG: 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 (2)
@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?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5207
BUG: Duplicated CSS while multi page creation
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome latest Reproducible demo link https...
Issue #3381
BUG: Switching between components gives maximum call stack size error
Hey artf, I would like to thank you for building such a powerful tool for building customized CMS. I'm implementing a new page feature in m...
Issue #1311
[Question]: Initializing Canvas Scripts and Styles dynamically
Hello Grapejs team, Thanks for this wonderful project saved my time and so far I had great experience with integration and your community s...
Issue #5354
BUG: canvas.script entries do not respect an "import map"
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Version 1.56.20 Chromium: 115.0.5790.171 (Of...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.