The gas dynamics were equally significant in the formation of the first galaxies. As the gas fell into the gravitational wells created by dark matter, it began to cool and condense. This cooling process allowed the gas to form molecular clouds, which are the birthplaces of stars. Eventually, these clouds fragmented and collapsed under their own gravity, leading to the formation of the first stars, known as Population III stars. These stars were massive and short-lived, and their supernova explosions enriched the surrounding medium with heavier elements, paving the way for the formation of more complex structures.