use beforeload instead of loadstart