angular
angular copied to clipboard
HTML escaper performance could be improved by adopting the same html escaping code as Svelte and Solid JS
Which @angular/* package(s) are relevant/related to the feature request?
platform-browser
Description
The html escape function provided in @angular/platform-browser is outperformed by newer takes on it from Solid JS and Svelte. packages\platform-browser\src\browser\transfer_state.ts
Proposed solution
Consider adopting the same method as Svelte for escaping html. The code can be found here: https://github.com/sveltejs/svelte/pull/5701 Also here's a js bench comparing the two functions for store serialisation. I made a js bench comparing the old/new approach, it needs this gist to be in the setup data: https://gist.github.com/callumelgrant/dde6f54cd1544c1be5524a74b5365cd6 https://jsbench.me/uyl5xdwloa/1
Alternatives considered
It could be possible to make an even faster one than Svelte's.
I made a draft PR for this https://github.com/angular/angular/pull/46951.
For more context, here is the article discussing the issue and improvements: https://levelup.gitconnected.com/how-we-wrote-the-fastest-javascript-ui-framework-again-db097ddd99b6
And here is a PR with the improvement itself in SolidJS: https://github.com/ryansolid/dom-expressions/pull/27
Closing as the escapeHtml
method has been removed.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.