As a performance improvement, make sure more complex actions like initiating OOUI widgets and DOM node lookups are only performed if necessary (i.e. no early returns) - from T260821#6600060.
In this example, complex objects are initialized then thrown away if the method returns early. We should refactor this to ensure these objects are only made when they are needed.