The slowing down of water waves upon entering shallower regions is not primarily due to a change in density but rather a consequence of a change in depth. When a wave encounters a region of shallower water, such as when it approaches the shore, two key factors contribute to its reduced speed:
Wave shoaling: As water depth decreases, the wave encounters the seafloor or bottom surface, which obstructs the motion of water particles near the bottom. This interaction causes the wave to compress and become steeper in order to conserve energy. Consequently, the wave's wavelength decreases, and its height increases. This phenomenon is known as wave shoaling.
Dispersion: In deeper water, water waves of different wavelengths travel at roughly the same speed. However, in shallower water, the shorter wavelengths experience greater bottom interactions and are more affected by the seafloor. This leads to a phenomenon called dispersion, where waves of different wavelengths travel at different speeds. As a result, the longer wavelengths (which correspond to slower speeds) dominate the wave profile, and the overall speed of the wave decreases.
It's worth noting that the density of water does play a role in wave propagation, but its influence on the speed of water waves is relatively minor compared to the effects of depth and dispersion. The decrease in wave speed as it enters shallower regions is primarily due to the combined effects of wave shoaling and dispersion, rather than changes in water density.