resourceloader: Consistently set state=ready after script execution (not before)