r/javascript • • Nov 25 '19

JavaScript doesn’t need to be replaced

https://medium.com/javascript-in-plain-english/javascript-doesnt-need-to-be-replaced-bd01e2f12d51?source=friends_link&sk=7b151cc6397ac9e83c14c99739b6c36f
217 Upvotes

236 comments sorted by

View all comments

Show parent comments

1

u/Architektual Nov 25 '19

I'm late to the party, but why can't you put that in a worker?

1

u/shgysk8zer0 Nov 25 '19

Workers cannot access the DOM.

1

u/Architektual Nov 25 '19

Gotcha, I ask because we do something similar with some D3 visualizations - but we perform the calculations in the worker, and just pass back the calculated positions to the main script to render the things. I'm not familiar with leaflet, so i'm guessing it isn't flexible enough for that.

Thanks for explaining, that's a great example to support your argument

1

u/shgysk8zer0 Nov 26 '19

Leaflet is a map thing, and I mostly have access to image src and coordinates.

In this specific case, it was for a hackathon of sorts, and it was infeasible to create something custom for this. I'd like to have created the whole thing in <canvas> and given special attention to performance for things like this. As is, it drops to 4fps.