Move syntax highlighting to web worker (#11017)
This should eliminate page freezes when loading big files/diff. `highlightBlock` is needed to preserve existing nodes when highlighting and for that, highlight.js needs access to the DOM API so I added a DOM implementation to make it work, which adds around 300kB to the output file size of the lazy-loaded `highlight.js`. Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
@ -51,6 +51,7 @@ module.exports = {
|
||||
sourceMap: true,
|
||||
extractComments: false,
|
||||
terserOptions: {
|
||||
keep_fnames: /^(HTML|SVG)/, // https://github.com/fgnass/domino/issues/144
|
||||
output: {
|
||||
comments: false,
|
||||
},
|
||||
@ -89,6 +90,19 @@ module.exports = {
|
||||
test: require.resolve('jquery-datetimepicker'),
|
||||
use: 'imports-loader?define=>false,exports=>false',
|
||||
},
|
||||
{
|
||||
test: /\.worker\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'worker-loader',
|
||||
options: {
|
||||
name: '[name].js',
|
||||
inline: true,
|
||||
fallback: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
|
Reference in New Issue
Block a user