Y
Y
yura007rt2019-04-08 00:43:03
JavaScript
yura007rt, 2019-04-08 00:43:03

How does resize affect performance if it is used multiple times on a page?

Hello everyone) The question is as follows. I understand angular and break everything down into components. How much does the resize event affect site performance if it hangs on several components, and does it affect it at all?. One component is a menu, and the content is another, and so on (I don’t know where else I need to keep track of the size and make changes to the component depending on the width and height). The effect of resize became interesting.
Example:
1) I track the change in the menu width and change the classes that are tied to one variable.
2) I track the height of the blocks under the menu and change their height depending on the change in the height of the window.
These events are tracked in different components. But all of them are displayed on 1 page.
Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2019-04-08
@yura007rt

How does <insert any event> affect performance if it is used multiple times on a page?

Subscribing to an event does not affect anything.
There may be one subscription, but you decide to rebuild the entire site, let's say.
It all depends on what you do there in your resizes.
So measure the running time of your code if there are suspicions of brakes and optimize if necessary.
Let's assume this is the norm. Though it might be possible to get by with CSS.
and this is exactly the layout and css media query
There is no point in hanging extra JS where CSS can handle it.
And Angular is completely off topic here. What's the difference what kind of framework you have there, anyway, everything rests on your code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question