Skip to content

feat(fluent-dom): Implement a new Localization class MiniDOMLocalization for projects that have a lot of roots - #673

Open
julienw wants to merge 1 commit into
projectfluent:mainfrom
julienw:mini-dom-localization
Open

julienw wants to merge 1 commit into
projectfluent:mainfrom
julienw:mini-dom-localization

Conversation

@julienw

@julienw julienw commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

This is an alternative to #671, as a way to fix #648 for us. It's probably less scary because it doesn't change the shape or behavior of DOMLocalization itself.

The new class doesn't use a MutationObserver which has performance problems when observing a lot of nodes. Therefore it's up to the users to call translateFragment or translateElements at the right moment.

It also doesn't check if a newly connected root overlaps with the previously connected roots because of the quadratic behavior of this check. It's up to the users of the library to take care about that. The possible drawback is to possibly translate the same elements twice when the locale change, which is a small drawback compared to the quadratic behavior.

The previously existing DOMLocalization is now based on MiniDOMLocalization, but otherwise doesn't change its API or behavior, so this change shouldn't be breaking for existing users.

…ion for projects that have a lot of roots

The new class doesn't use a MutationObserver which has performance
problems when observing a lot of nodes. Therefore it's up to the users to
call `translateFragment` or `translateElements` at the right moment.

It also doesn't check if a newly connected root overlaps with the
previously connected roots because of the quadratic behavior of this
check. It's up to the users of the library to take care about that. The
possible drawback is to possibly translate the same elements twice when
the locale change, which is a small drawback compared to the quadratic
behavior.

The previously existing DOMLocalization is now based on
MiniDOMLocalization, but otherwise doesn't change its API or behavior,
so this change shouldn't be breaking for existing users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using Fluent with a lot of roots is slow

1 participant