It's technically possible to do that, but it's kind of a pain. I asked about server-side JS because the server is where I'd do something like this as my first choice.
If you really want to do it in the browser, you could use an AJAX call to get the html from the server, then use DOM functions to find that snippet by id. (Or just put them in separate html files and save yourself the pain of those DOM functions.)
I found this for you. https://gomakethings.com/getting-html-with-fetch-in-vanilla-js/ I think it actually has most of what you want to do.