Accessing $site->url() from javascript

How would you recommend I access $site->url() from within a js file ?

I was using a base tag on my header, but that causes problems with svg’s url() and gradient fills.

Thank you

Why don’t you use window.location.hostname?

If you have to use $site->url()you can. either get that information via an Ajax call from. the server or print it out somewhere, for example using a data attribute you can. the read from the DOM.

Actually you are right. Ajax messed with my brain.
Thank you