External JS script loads only sometimes AND onRendered not working as expected

Hello,

I am new to meteor, and sometimes I struggle with some JS concepts.

I have a small app that loads a bible highlighter on head tag. This is the result when the thing works…

Every passage becomes a link.
I have two problems.

  1. I need to refresh the page every time to make this work. If I change the page and came back all the links go away.
    this is the JS loaded in the head tag
// some css loads before, no other scripts
...
(function(w, d, s, e, id) {
            w._bhparse = w._bhparse || [];
            function l() {
                if (d.getElementById(id)) return;
                var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
                n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
                x.parentNode.insertBefore(n, x);
            }
            (w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
        })(window, document, 'script', 'load', 'bw-highlighter-src');
        </script>
    </head>
  1. I need to add some values to a dict AFTER the template loads. This only works sometimes. When it not works, console log tells me: TypeError: Cannot read property ‘highlighterBooks’ of undefined.
// highlighter routine. rally is the template where the links are loaded.
Template.rally.onRendered(function(){
    if(!this._rendered) {
        this._rendered = true;
        console.log('Template onLoad');
    }
    window.BIBLESEARCH.highlighterBooks['Ps'] = "sl,ps,psa,psalm,psalms";
    console.log(window.BIBLESEARCH.highlighterBooks);

});

I am sorry if this is a dumb question, but I really could not find a similar problem, where these JS scripts not being loaded all the time.

Any help would be appreciated.