These are chat archives for ractivejs/ractive

22nd
Sep 2017
lazylester
@lazylester
Sep 22 2017 20:33
Please check my thinking here... I'm looking at performance optimisation... it seems to be a good idea to set "far-futures" header on templates and let the browser cache them, no? They would need a digest appended, the way Rails does in its asset pipeline, to handle the infrequent case where the template changes. Does it make sense to pre-parse the templates and embed them as a string in the javascript code for each model in a page? This way Rails would take care of appending digests to the filenames. Does this make sense? Or maybe it's obvious and I've just realized it!
Joseph
@fskreuz
Sep 22 2017 20:38
I'm not familiar with Rails, but the parse-embed routine is one way to optimize Ractive (parse template, embed the object output as template)
Chris Reeves
@evs-chris
Sep 22 2017 20:39
you will absolutely get a good performance kick by using pre-parsed templates
does the rails pipeline include something like webpack these days?
lazylester
@lazylester
Sep 22 2017 20:41
I think it does, Chris, I'm not really familar with webpack, though. I'll look into it.
In a build procedure, how would you embed pre-parsed templates into the javascript?
Joseph
@fskreuz
Sep 22 2017 20:42
I think the ractive bin handles this embedding.
And if I remember correctly, rvc also did something similar (converted component files into AMD modules with pre-parsed, embedded templates). I remember doing this stuff with grunt, grunt-contrib-requirejs and a grunt-rev. You can probably take inspiration from this.
lazylester
@lazylester
Sep 22 2017 20:44
@fskreuz regarding the ractive bin approach you mention... how does it work. I invoke the parser on the template and produce a preparsed template string. How does it get embedded into the js code?
Feed it a component file, and out comes an ES module.
Was designed for pre-processing for other build tools (i.e. webpack)
An older implementation would be rcu and rcu-builders (see https://github.com/ractivejs )
rcu has APIs to parse through a component file. rcu-builders has APIs to emit various module formats.
lazylester
@lazylester
Sep 22 2017 20:53
That looks good, Joseph, I'll dig in and see if I can figure it out. Dumb Rubyist here... way out of my depth on JS! Thanks for your tips, guys.