Random extreme CPU spikes on random browser tasks
Here are a few steps you can check:


Do you use Safari extensions? Try uninstalling unused or non-trusted Extensions.
Do you run Java in Safari? Disable the java browser runtime
This sounds too easy, but did you clear Safari Caches and Cookies? Sometimes quitting Safari without restoring windows may help resolve issues.
Go to Safari Preferences and turn off the autoplay video feature for all sites.
If you never clear your Cache the ~/Library/Safari/RecentlyClosedTabs.plist file generates huge file size. Quit Safari and move RecentlyClosedTabs.plist to the trash