I have:
var Init = (function() { my js goes here })();
And my js executes correctly when the page is loaded. I also have:
Quick one Try replacing like this
var Init = function() { my js goes here });
and on load call Init