You are working with EmberJS here, not vanilla JavaScript. It will not behave the same.
Best to follow EmberJS best practice.
I would consider piggybacking your logic onto an existing component or adding one to a plugin outlet and using the didInsertElement hook.
Read the EmberJS Guides