-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Time overhead when adding many elements under a same HTML element #1191
Comments
I think the issue is adding elements one at a time to the page, you really need to add them together as a single block. |
Thinking a little more, it might help if that loop were denounced to next animation frame by using
My health isn’t great at the moment and don’t have much energy to play with this, but it would be great if you give this a go and make a PR if it works. |
Finally have time to look at this, but I will need a simple case added to the examples to be able to test it. |
I'm working on v5 #1212 which changes how mutationObserver is used. Would be interested to know if it helps with your issue. |
Describe the bug
When adding, for example, 1000
<div>
elements under a same bootstrap.row
element, in a child iframe page, the overhead before the page gets rendered can grow exponentially.Adding 1000 items inside 1 row, autoResize=true : addImageLoadListners measured 1min30 in my context.
Adding 6 items inside ~166 rows each: addImageLoadListners measured ~2,5 seconds in my context.
Adding 1000 items inside 1 row, autoResize=false : addImageLoadListners no overhead obviously
To Reproduce
Steps to reproduce the behavior:
autoResize=true
In my case [...stuff...] can get complex, I suppose the overall time spent really depends on this.
Replace vuejs directives by any javascript that would insert the 1000 items 1 by 1 inside the bootstrap
.row
.Expected behavior
It probably should not take so long.
For now I will add the overhead to split rows where needed, as it mostly workarounds the problem, this issue is to let you know about this finding.
Desktop
Additional context
Instrumenting shows that time is spent in iframeResizer.contentWindow.js, inside setupBodyMutationObserver(), here (line 554):
This is repeatedly called on the same element, while it is growing 1 by 1 due to how VueJS adds children with the v-repeat. Almost all the time seems to be spent on the querySelectorAll.
Only solution I can think of (except splitting rows appropriately of course) would be to allow deactivating mutationObserver before changing the list, then reactivating it after, dynamically, which currently is not possible if I'm not wrong. Also in this case we would want it to run after re-activation, so iframe height gets properly computed once the whole list is displayed (and not: after each element is added).
Alternatively it could be enough to have an option to deactivate image load listeners altogether, or to have a way to exclude their creation based on some tag inside html markup ? It's a bit convoluted.
Note: not tested on iframeResizer v4, I use v3 for compatibility.
The text was updated successfully, but these errors were encountered: