It's amazing that this kind of simulation can be done so accurately with javascript in a web browser. I have no idea how it was implemented but the computational load must be nontrivial.
I haven't looked at the code but it's likely some out-of-the-box physics engine, many of them available in JS. They often have to employ many more complex physics features. Buoyancy is just one of them. Computationally I'm sure it's complex, but it's made to run at game tickrates, less than the max budget of 16ms at a time.