May be clearer if the check is just for 'loading' state. If the state is 'loading', then wait for DOMContentLoaded, else install on the subtree.