How about you stop trying to make me buy useless crap for my Mac? This is a 2012 iMac with a perfectly fine hard drive and it now has problems when running Mountain Lion which is an OS EARLIER than it even shipped with.
NONE of this happened until I upgraded to High Sierra, now its almost manifesting itself like a virus wherever I go... I can downgrade my OS, do a clean install, wipe the drive, reset my PRAM and SMC, and it STILL happens. If the HDD was going bad the problem would be happening more often instead of just at very specific times when Safari is loaded.
Take this scenario, I can run Parallels with Windows 10 for over 16 hours (Fallout marathon) and not have a single bit of lag. The Parallels virtual drive takes up half of my 1TB hard drive so if any of that data is bad Parallels would be acting goofy and sluggish.
I close down Parallels, come back to High Sierra and watch a little YouTube/Browse Facebook and 20-30 minutes later oh look everything is beachballing.
So please, take your SSD sales-pitch and go blow your nose with it.
If you honestly believe your HD is fine then please make a bootable Linux USB, boot into and run a SMART report from there. I can 100%, without a shadow of a doubt, guarantee that it will have read and seek errors. How do I know? I replace easily 5 a week for this exact reason.
If it’s not hardware related then answer me this: why would it follow to a COMPLETELY different operating system? The two OSes have nothing to do with each other. What’s the underlying common denominator? You guessed it, hardware.
When troubleshooting you have to start somewhere. That godforsaken HD is the first place I’d start. You wouldn’t even need to move to a SSD, just off of that particular drive. Another thing to consider, HDs are wear items just like tires on your car. Generally best replaced before 5 years....your iMac is a 2012. Would you keep driving on the same tires til you’re riding on the rim and then complain?