-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
MUTATION_OBSERVER poor performance (observe method) #14368
Comments
Hi! Thanks for being part of the Font Awesome Community. @robmadole could you please take a look at this? |
Mutation observer is attached to my |
@rafalpospiech the MutationObserver by it's very nature needs to examine changes to the DOM to see if there is are any changes that it needs to generate icons for. There is currently no way to tell it to ignore certain parts of the page. You can control where the mutation observers starts, though. I don't know if this will help you or not. You mentioned that you are using Vue. Can you switch to our Vue component? |
No, Vue is used just by this one component :/ |
But take a look at this example (line 23) https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver#Example You can observe specific nodes only without subtree and with childnodes only. So theoretically we can get all elements on the page and observe only those that doesn't have an attribute let say If observer will be on each element there could be an option to specify which elements to observe and which exclude from observation.
Or by default observe all excluding those with |
@rafalpospiech when brand new elements are added to the page how would we detect those? And with regard to your |
Same issue with angular 15 and fontawesome 6 While the icons are used in a static part of the page, the main portion (which is a calendar) renders many, many many dom elements. Adding fontawesome drops performance from 3s for a complex year view to an entire minute and a half! |
I'm having this problem as well in a SvelteKit application that builds a page that contains hundreds of icons. The FontAwesome mutation observer blocked the UI thread for around 8s on page load. I resolved it by using FontAwesome in pure CSS mode (CSS + WebFont, no JS). |
@dbrgn you can also take a look at https://github.com/FortAwesome/svelte-fontawesome |
@robmadole I tried, but FortAwesome/svelte-fontawesome#7 In the end, I'm actually happier with a pure-CSS mode, I don't need any of the dynamic features 🙂 |
I just hit this drawing some SVGs in a Vue app. Would it be feasible/useful to expose something like edit: I'm using 6.5.2, and I see
That looks like it will disable the observer, don't see anything regarding turning it back on though. |
There is a huge performance drop while MUTATION_OBSERVER is enabled.
I have component on my page that uses SVG to display some content.
This content is reactive and works on vue.
There are a lot of mutations going on so MUTATION_OBSERVER is running like crazy all the time.
I don't want to disable observer globally.
Is there a way to exclude from observation some parts of the page? by class or id?
I'm using Font Awesome Free 5.5.0
The text was updated successfully, but these errors were encountered: