If you're able to parse templates on the server, or as part of a build process, you can use ractive.runtime.js instead of ractive.js in your app. It's slightly smaller, and it means that browsers are spared having to parse templates on the client (though this is a very quick process for all but the most complex templates).
In effect, instead of doing this...
var ractive = new Ractive({
el: 'body',
template: '<h1>Hello {{name}}!</h1>',
data: { name: 'world' }
});
...you're doing this:
var ractive = new Ractive({
el: 'body',
template: {v:1,t:[{t:7,e:"h1",f:["Hello ",{t:2,r:"name"},"!"]}]},
data: { name: 'world' }
});
An easy way to automate this process is to use a component loader such as rvc for RequireJS, or ractify for Browserify, or broccoli-ractive.
Questions:
ractive.js
andractive.runtime.js
in mybuild.js
file? And, if so, how do I do that?My
main.js
config file (for development) is usingractive.js
at the moment:If I swap this to
ractive.runtime
I get an error when I load the development (i.e. non-optimised) page. So I tried adding:to my
build.js
file, so that the development site gets the full version and the build gets the runtime version, but then ther.js
build step doesn't work.Thanks!