You can make a second step, and load it when its needed (or not load when its not needed - i assume not every page needs it).
Simplified example for prism.js:
if ($q('code[class*="language-"]')) { import(/* webpackChunkName: "syntaxHighlighting" */ './js/syntaxHighlighting'); }
Notes:
const dynamicImport = p => import(`modules/${p}`).then(m => m.default())
And then call it from your js, when something happens.
If dev.to wasnt so heavy into react i could do some good with my webpack knowledge, but i dont want to get dirty with all the abstractions in there ;)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.
re: We reduced our vendor.js from 210kb to 16kb in about five minutes of work and ten lines of code VIEW POST
FULL DISCUSSIONYou can make a second step, and load it when its needed (or not load when its not needed - i assume not every page needs it).
Simplified example for prism.js:
Notes:
And then call it from your js, when something happens.
If dev.to wasnt so heavy into react i could do some good with my webpack knowledge, but i dont want to get dirty with all the abstractions in there ;)