Fix performance measurements for onLoad.

Performance measurements need to be collected after the onLoad event
finishes to get the correct time for the onLoad event.

This is a port of the fix by @skoenen from the HHU theme.