3 ms·
But that's what my code does, albeit my code loads only on demand (plus can be easily improved to load any further language dynamically), whereas your code stat
by Eduard 3y ago
But that's what my code does, albeit my code loads only on demand (plus can be easily improved to load any further language dynamically), whereas your code statically bundles everything into the main bundle (if not using proprietary Webpack chunk comments, which I see as antipatterns).
- capableweb 3y agoSure, but it's far away from "pulls in over a Megabyte of hundreds of programming language syntax definitions" as you said: 76K node_modules/highlight.js/lib/core.js 20K node_modules/highlight.js/lib/languages/javascript.js But I agree with you, that you probably want to only load it when really needed, especially if your total budget is 500kb which this would take a big part of it already. Edit: I see now their budget was actually more than 1MB actually, as they for some reason only "really care" about gzip'd sizes... Then I wouldn't say it's so bad to just say fuck it and do it the easy way. Saves any latency introduced by lazy-loading it too.
- c-hendricks 3y agoDynamic imports aren't unique to webpack, they're a standard feature. The two different variants written are six of one half a dozen of the other. There's nothing stopping you from writing the imports + register in one file and dynamically importing it in a dom loaded event in another.