Compiled template reference is undefined when calling dust.loadSource() in browser-Collection of common programming errors

I’m trying to render HTML using compiled templates with dust.js in a browser (not server-side with node.js). If I compile the template in the client-side javascript, it works fine. If I pre-compile the template and include it as a script tag as recommended, the dust.loadSource statement results in the Chrome debugger saying: “Uncaught ReferenceError: nowork is not defined”, where “nowork” is the template name. So…

This HTML and script works:




    
    This Works
    
    


    
    
        var templateKey = 'works';
        var myView = {"people":[{"name":"Fred"},{"name":"Harry"},{"name":"Linda"},{"name":"Mary"}]};

        dust.loadSource(dust.compile("{#people}
{name}{/people}", templateKey)); dust.render(templateKey, myView, function(err, out) { $('#bingo').html(out); });

But this doesn’t:




    
    This Doesn't Work
    
    
    


    
    
        var templateKey = 'nowork';
        var myView = {"people":[{"name":"Fred"},{"name":"Harry"},{"name":"Linda"},{"name":"Mary"}]};

        dust.loadSource(templateKey);
        dust.render(templateKey, myView, function(err, out) {
            $('#bingo').html(out);
        });
    


Where the included nowork.js file contains:

(function() {
    dust.register("nowork", body_0);

    function body_0(chk, ctx) {
        return chk.section(ctx.get("people"), ctx, {
            "block": body_1
        }, null);
    }
    function body_1(chk, ctx) {
        return chk.write("
").reference(ctx.get("name"), ctx, "h"); } return body_0; })();

Can anyone help?

I just realized, that this may be due to these files not being served on a machine with node.js installed. I’m actually working locally on my desktop machine. Is that it?