Once this object begins to collapse under its own gravity, it is called a protogalaxy . The first protogalaxies appeared about 14 billion years ago. Gas can dissipate its energy through collisions. Dark matter does not interact this way and continues to orbit in the halo. As the gas in the protogalaxy loses energy, its density goes up.
Gas clouds form and move around in the protogalaxy on orbits.
When two clouds collide, the gas is compressed into a shock front. The first stars in a galaxy form in this manner. With the production of its first photons by thermonuclear fusion, the galaxy becomes a primeval galaxy. Star formation sites in primeval galaxies are similar to star forming regions in present-day galaxies. A grouping of young stars embedded in a cloud of heated gas.