Issue #3449Opened May 11, 2021by chiragkataria220 reactions

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)

chiragkataria22May 12, 20210 reactions

@artf Can you please help?

artfMay 22, 20210 reactions

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.

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.