Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML escaper performance could be improved by adopting the same html escaping code as Svelte and Solid JS #46950

Closed
cgranttm opened this issue Jul 23, 2022 · 4 comments
Labels
area: core Issues related to the framework runtime area: server Issues related to server-side rendering bug core: performance P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@cgranttm
Copy link

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: sveltejs/svelte#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.

@cgranttm
Copy link
Author

I made a draft PR for this #46951.

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime area: server Issues related to server-side rendering labels Jul 23, 2022
@ngbot ngbot bot added this to the needsTriage milestone Jul 23, 2022
@pkozlowski-opensource
Copy link
Member

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: ryansolid/dom-expressions#27

@pkozlowski-opensource pkozlowski-opensource added core: performance P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent bug labels Aug 17, 2022
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Aug 17, 2022
@alan-agius4
Copy link
Contributor

Closing as the escapeHtml method has been removed.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2023
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime area: server Issues related to server-side rendering bug core: performance P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

3 participants