bedrock icon indicating copy to clipboard operation
bedrock copied to clipboard

Decrease prototype bundle size

Open Wolfr opened this issue 3 years ago • 5 comments

The prototype JS bundle size of Bedrock is 842kb.

How can we minimize the size?

Ideas

  • Switch from codemirror to prism
  • Remove jQuery
  • ...? Suggestions welcome!

Wolfr avatar Jun 08 '21 13:06 Wolfr

New suggestion: minify the bundle.

This could also be tied to a setting: production or development build.

I discovered CodeMirror is by far the biggest dependency, it weights 400-500kb if I recall correctly.

Wolfr avatar Jun 09 '21 06:06 Wolfr

New suggestion: minify the CSS bundle as well.

Wolfr avatar Jun 15 '21 21:06 Wolfr

Minification was implemented, Prism code blocks are in progress, the removing jQuery part is partially handled but needs more work.

Wolfr avatar Jul 08 '21 09:07 Wolfr

  • core-prototype-nav.js: 95kb minified
  • core-style-guide.js: 126kb minified

It can be better but it's more reasonable. One problem, because of the splitting of prototype nav and core styleguide, jQuery is included twice.

If we would rewrite styleguide-search (27 LOC) to use vanilla JS, we would be able to throw jQuery out of core-style-guide.js and save those bytes.

Another option would be to include jQuery before everything.

Wolfr avatar Jul 19 '21 16:07 Wolfr

rememberScroll also uses jQuery. In 7cf5e4715a2023b5b2fcb7ae2d9782dfe0c46d00 I tried to remove it, seems to work.

Wolfr avatar Nov 16 '21 11:11 Wolfr