I have a huge SVG which has lots of graphical elements, on mouse wheel zoom event gets triggered which re-paints the whole SVG. With some profiling I could break down the time taken in such event,
- Calculations needed to transform the SVG are taking 1-2ms.
- Upon applying the transform, the paint operation is taking 500ms-1.5sec(very sluggish user experience).
As I understand, the paint operation would depend on the render tree of the SVG/HTML which is quite big in this case. I thought of trying the following ways to improve the user experience
- Use 'debouncing' so that I will coalesce mulitple scroll events into one signal within a given interval.
- Possibly use 'requestAnimationFrame' with 'debouncing'.
- Look for ways to optimize the render tree of the SVG although I feel this is difficult in my case because of other constraints.
Are these the right ways or am I moving in the wrong direction? What other techniques could be used for a smoother user experience in such cases when re-painting is inevitable?