This is probably an issue with RequireJS and the fact that the page is already loaded. RequireJS should already be waiting for all the files to load so use the below code.
Example:
console.log("main.js ran");
function render() {
console.log("render ran");
}
render();
If you are trying to wait for an HTML element to load use jQuery:
//will run once the page DOM is ready
$(element).ready(function(){
...
});
//will run once the entire page is
//loaded including images and iframes
$(element).load(function(){
...
});