Then, lower your cache sizes. Modern browsers (and OSes) won't let your RAM sit empty if they can fill it with data that you might use later. Check about:cache. If you want, set browser.cache.memory.capacity to an actual value instead of -1. It's in kilobytes, so multiply accordingly. http://kb.mozillazine.org/Browser.cache.memory.enable Or disable browser.cache.memory.enable entirely.
Modern browsers run different sites in different processes for security. If you're not that worried about it, you can disable this in Firefox by setting browser.tabs.remote.autostart to false. Now when a tab crashes it will kill your whole browser, but it will use less RAM. Remember to restart your browser for these changes to work.
Finally, check in about:performance to make sure you don't have some extensions hogging RAM.
I'm not aware of another solution that avoids both problems at the same time beyond blocking ads and trackers. The modern web can't be fixed directly from the receiving end. We do have a choice which sites we visit, though.
Browsh: The modern text-based browser - https://www.brow.sh/