chovy
chovy

Reputation: 75834

using handlebars with precompiled templates not loading

I have the following code, but I still get the following error when templates.js loads:

Uncaught ReferenceError: Handlebars is not defined

Here is how I'm loading the required scripts (first handlebars, then the precompiled tempaltes):

    var scripts = [
      '//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.min.
js'
      , '/templates/templates.js'
    ];

    $.each(scripts, function(i, script){
      var el = document.createElement( 'script' );
      el.src = script;

      $body.append(el);
    });

But in the console I get this error:

Uncaught ReferenceError: Handlebars is not defined

Upvotes: 0

Views: 1051

Answers (1)

Rok Burgar
Rok Burgar

Reputation: 949

It's not so simple. Not all browser will load and use those js files in the same order that you specified (Dynamic script loading)

Think about using requirejs

Upvotes: 1

Related Questions