It is well known that when a short laser pulse propagates in an underdense plasma, it induces longitudinal plasma oscillations at the plasma frequency after the pulse, typically referred to as the wakefield. However, for plasma densities approaching the critical density, wakefield generation is suppressed, and instead the EM-pulse (electromagnetic pulse) undergoes nonlinear self-modulation. In this article we have studied the transition from the wakefield generation to formation of quasi-solitons as the plasma density is increased. For this purpose we have applied a one-dimensional relativistic cold fluid model, which has also been compared with particle-in-cell simulations. A key result is that the energy loss of the EM-pulse due to wakefield generation has its maximum for a plasma density of the order 10% of the critical density, but that wakefield generation is sharply suppressed when the density is increased further.