That looks wrong. You can't manipulate the dom before document.ready.
Should be ok. It is loaded as a RL module. At the time of module loading the dom should be ready (or at least all dom elements should be present).
That's not true. Modules loading before dom ready caused lots of hard to debug javascript issues when 1.19 was deployed to WMF.
So what do you suggest?