mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-24 18:10:52 +00:00
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:
parent
cc4da79fb6
commit
27e3cddfbe
7 changed files with 83 additions and 17 deletions
|
@ -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/,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue