Hard refreshing the page isn’t advised every attempt should be made to make customizations dynamic to simply update the current pages metafield data.
Unless you specifically know it wont be a user annoyance; any page you do this on should have accompanying a/b testing or at minimum analytics to monitor bounce rates or you risk hemorrhaging money in lost conversions.
Always backup themes before changing files
In symmetry that may be
document.querySelector('select.original-selector').addEventListener('change',function () {
console.log("variant changed");
window.location.reload(true);
});
reload(true) is used to try and avoid the browser cache.
Know the difference between .reload and .href
https://stackoverflow.com/questions/41020403/reload-a-page-with-location-href-or-window-location-reloadtrue
If you need this customization made dynamic contact me directly for services.
Please always provide context, examples: store url, theme name, post url(s) , or any further detail.
Contact Info in signature.
Generally for any theme this is done by adding something like the following to the MAIN target selectors or form.
mainSelector = document.querySelector('select.classnameorID').
mainSelector .addEventListener('change', callBack);
For symmetry the element to target is select.original-selector
The "selectors" such as button/dropdown/swatches that you see visible on page, *or initially inspected in devtools*, may not be the main input as that's often style with display:none;
Alternatively listen for a more specific events like onVariantChange, variant:change,etc some themes emit.
For most themes to find the exact verbiage used to name the event you need to look in either:
the main javascript file, theme.js, script.js etc,
the product sections javascript product.js, product-form.js etc
the blocks component javascript such as in a variant-picker snippet.
*Dawn based themes are using a pub sub model which can be confusing to find the event names for theme features.*