JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.01k stars 272 forks source link

[Performance] Use macrotask to improve `mount` performance when we have many svg files #436

Closed Aqours closed 3 years ago

Aqours commented 3 years ago

Do you want to request a feature, report a bug or ask a question?

Request a feature

What is the current behavior?

image

The total mount time is too long when there have many svg files.

What is the expected behavior?

Use macrotask to improve mount performance

If this is a feature request, what is motivation or use case for changing the behavior?

Long task will block browser interaction if mount take long time.

Please tell us about your environment:

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Aqours commented 3 years ago

https://github.com/JetBrains/svg-sprite-loader/blob/d2165576cab02ec59d6d6eb6b0346d5bfd14fa9b/lib/runtime-generator.js#L48

It seems that I could override this line with window.setTimeout(function() { sprite.add(symbol) }) on config.runtimeGenerator to improve mount performance.

Close.