Passing a variable to a snippet from Javascript

I want to hide certain elements based on the zoom level of the page, which we’ve implemented for accessibility reasons. I figured the best way to do so would be to just pass the zoom level variable to the snippet where I can just use php to only show the zoom out button if someone has already zoomed in. However I couldn’t really find out how to pass a Javascript variable without clunky workarounds. I’m not exactly sure if I should use the js() method since I only want to pass a single variable? I have the classic main.js file under /assets and the snippets under /snippets. The button itself is on the navbar which is a nested snippet in the header.

Thanks!

Hm, you would have to use a session cookie, as you cannot just pass something from the frontend to the backend.

However, maybe it makes more sense to just hide the stuff via CSS.

I would go that route. Add a class so you can pick up on when the zoom gets clicked, and dont forget there are no clicks on a mobile device, so you need to work on a tap as well.