4 ms·
Well in my case I wrote a little packer / minifier for compiled Jade (http://jade-lang.com/ http://jade-lang.com/) templates and serve them as a single JavaScri
by elisee 15y ago
Well in my case I wrote a little packer / minifier for compiled Jade (http://jade-lang.com/ http://jade-lang.com/) templates and serve them as a single JavaScript file.
When you have different templates based on user rights, you should probably make different packed template files and serve them only to users with the proper cookie / session rights.
I'd serve an admin page / app at a specific URL and then it would reference the proper template JS file (or whatever you're using).
Either way I wouldn't worry about the extra few bytes served for rarely used templates, just make sure the template file is properly cached. Or serve it as a different file and load it asynchronously when needed.
- swah 15y agoOh yes, its not the page size I worry about, but whether the template already has some info that you don't want to share (OK, probably most interesting info is dynamic, but anyway)
- elisee 15y agoIf anyone's interested, I put up the code I wrote for packing Jade templates into a single file and serving them to the client with Express: http://pastebin.com/kRtCJHYH http://pastebin.com/kRtCJHYH (feel free to do whatever you want with it) I found there were very few good alternatives for using Jade template client-side. The only one that seems promising is JadeVu (https://github.com/LearnBoost/jadevu/ https://github.com/LearnBoost/jadevu/) but the approach is very different.