In fuel-injected spark ignition [SI] engines, fuel is always injected into the air charge
well before ignition takes place. This is necessary because the liquid or gaseous fuel must be thoroughly mixed together with air into a combustible mixture and then be ignited by the electrical arc generated by the sparkplug. If the ratio of air to fuel is not reasonably close to 15:1 in the vicinity of the sparkplug, the mixture will not ignite at all and a miss-fire results.
Compression ignition [CI] engines always inject the fuel charge directly into a combustion chamber in the engine. Fuel injection and ignition are inextricably tied together in compression ignition [CI] engines. Recall that CI engines only work because they compress the air charge so that it is hot enough to instantly ignite the fuel charge as it is being injected. The combustion of the fuel begins at the instant it begins being injected (within a couple of milliseconds) into the combustion chamber full of very hot air (more than 400 ºC).
This means the timing of ignition is intimately tied to the fuel injection process. So, the fuel injection system of a CI engine is responsible for regulating both the quantity of fuel to be injected and the timing at the very start of combustion. Many ingenious techniques have been developed to achieve both these tasks with admirable accuracy, long before the advent of sophisticated electronic controls.
As you can see, diesel and petrol/gasoline engines go about the task of releasing energy from their fuels in quite different ways. For more general information on this topic see our
Why Diesels are Different article.