That doesn’t sound like a good solution to me. What if JS is disabled/doesn’t load? And why put the burden of extra processing on the device and browser?
If you are working on WordPress sites for clients, I’d say it would be much more useful to learn how to edit the HTML properly, rather than looking for shortcuts and work-arounds.
The theme will have a header.php file, but you really should not edit the theme itself. Any changes you make will be overwritten when an updated version of the theme is installed.
You should do all of these changes in a child theme of your theme.