### URL

_No response_

### How to reproduce the issue?

I was trying to figure out why the Map Data layer is slow when displaying a lot 
of elements. In Firefox Profiler, I saw that a lot of time was spent on 
handlers for adding new objects to the map.

<img width="1360" alt="Снимок экрана 2025-01-04 в 21 18 56" 
src="https://github.com/user-attachments/assets/ebef23e6-1286-46af-a411-9b1fecfaa5f2";
 />


https://share.firefox.dev/4a3ZXM9

Specifically:
https://github.com/openstreetmap/openstreetmap-website/blob/95b919c5d1e33688b0841c7d38602372c2e4c4a3/app/assets/javascripts/index.js#L176-L184

I don’t understand why these handlers need to update data about the current 
coordinates, and to prove their uselessness I did the following:

1. Updated the page with Map Data enabled
2. Waited for the data to download
3. Allowed display of a large amount of data

Rendering took a few seconds. 

After that, I did the same thing, but deleted the handlers with 
`map.off("layeradd layerremove")`. After that, the rendering is understated for 
less than a second.

https://github.com/user-attachments/assets/f8232635-7e97-4bd1-87ab-1d46b7b79e70

Further movement of the map is also noticeably faster and allows you to display 
tens of thousands of objects.

Note: `map` variable is not available by default, it is provided by my 
better-osm-org extension. This extension doesn't do anything else, and 
rendering performance doesn't depend on how it works.

You can also analyze the performance profile collected in the video: 
https://share.firefox.dev/4a3ZXM9






### Screenshot(s) or anything else?

_No response_

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/5466
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/issues/5...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to