How to set querystring with Javascript
It is possible, but it will refresh the page.
document.location = "?facets=bar";
If you don't care about browser support, you can use the HTML5 history.pushState.
const params = new URLSearchParams(location.search);
params.set('test', 123);
params.set('cheese', 'yummy');
params.toString(); // => test=123&cheese=yummy
window.history.replaceState({}, '', `${location.pathname}?${params.toString()}`);
You can use Javascript to change the hash (the #hash-part of the URL), but changing the query string means you have to reload the page. So, no, what you want to do is not possible in that way.
An alternative is to use Javascript to change the hash, then check the hash on page load to change your results dynamically. You're looking for something like jQuery Address.