We currently VueJs and apply the toImage function on a lot of components independently.
The toImage function builds the regex for the emojis every single time. After doing a detailed performance analysis, the toImage function spend most of its time to build the regex. Caching the result of these two functions immediately improved performance.
Even more: function replaceAll is actually called with the same find parameter all the time. Therefore search variable is also const. No need to compile regex every time.
We currently VueJs and apply the toImage function on a lot of components independently.
The toImage function builds the regex for the emojis every single time. After doing a detailed performance analysis, the toImage function spend most of its time to build the regex. Caching the result of these two functions immediately improved performance.