Javascript functions as echo, not just php... possible?

I’d like to have a sticky element that is offset from top by the height of a div. That div can change based on what gets pushed into it. Its navigation and has post taxonomy tags… so it could grow in height.

I know how to use a JS function to set the required CSS to accomplish this, but instead of having to target each element with more JS code, I’d like to have a universal JS function that I pass an argument into, with the px value offset returned. I’m wondering if there is any one who has referenced the result of a function into a bricks field, such as “top” property for sticky offsets. I know echo and how to use for PHP, but is it possible to do the same with a javascript function running in on the page?