Improve javascript onload handling.