JS code ordering