Need a page refresh everytime a variant changes to get the correct code to load

Thanks. I tried this but couldn’t get it to work. I’ll go back to the way it was before because it was working great. Thanks again.