Search code examples
javascriptmeteoriron-router

Wait On Lib (IronRouter) causing HTML to not load after loading JS file


I'm using wait-on-lib with IRLibLoader.load() combined with Iron-Router, based on this tutorial: http://www.manuel-schoebel.com/blog/use-meteor-iron-router-waiton-to-load-external-javascript. I am trying to load external javascript code. Here is my routing code:

Router.map(function(){
    this.route("home", {
        path: "/",
        waitOn: IRLibLoader.load("/alert.js")
    });
});

The javascript loads perfectly. The problem is that whenever I am loading js files, it prevents the HTML from loading.

I have 3 files and one directory

-- test.html
-- test.js
-- test.css
-- public
---- alert.js

alert.js is a JavaScript file with one line of code: alert("hello");

In my test.html I have a template named home with an h1 tag inside of it. This h1 tag is no longer loading.


Solution

  • I think correct syntax for this is:

    waitOn: function(){
         return [IRLibLoader.load("/alert.js")]
    }
    

    just like the subscriptions.

    Also, in url you posted there is correct syntax, just like the one above.