Optimus <https://github.com/magnars/optimus> is a Ring middleware for 
frontend performance optimization.

In order to do its optimization, it needs to rest on a first-class asset 
concept in the Ring stack. So the most basic operation of Optimus is 
serving assets from a list, with this minimal structure:

[{:path :contents}]

It serves the :contents if the request :uri matches :path.

Built on top of that is a bunch of operations that either help you:

   - Load assets to put in the list
   - Optimize the assets in the list somehow
   - Decide how you want to serve the assets
   - Link to the assets

For instance, transformations that change :path also set :original-path so 
that the linking functions can refer to a known name.

So, Optimus is a replacement for compojure.route/resources, that includes a 
separate middleware stack for asset transformations.

I'm announcing optimus-less <https://github.com/magnars/optimus-less> and 
optimus-angular <https://github.com/magnars/optimus-angular> which both 
show some interesting ways to extend Optimus.
<https://gist.github.com/magnars/4b1f32a76523a4b39ef8#optimus-less>Optimus 
LESS

Even tho Optimus itself doesn't do transpiling, building a transpiler to 
use with Optimus is pretty nice. I created 
optimus-less<https://github.com/magnars/optimus-less> as 
an example implementation.

Optimus LESS declares load-less-asset as a custom loader for .less files 
with Optimus' load-assetmultimethod. This is in turn used by load-assets, 
load-bundle and load-bundles - so everything works like before, but now it 
also supports LESS files. Score!

It's about 20 lines of 
code<https://github.com/magnars/optimus-less/blob/master/src/optimus_less/core.clj>,
 
including requires. And adding support for more transpilers require no 
changes to Optimus itself.
<https://gist.github.com/magnars/4b1f32a76523a4b39ef8#optimus-angular>Optimus 
Angular

This project offers two distinct features. It helps you:

   - Prepopulate the Angular.JS template cache.
   - Prepare JavaScript for minification with 
ngmin<https://github.com/btford/ngmin>
   .

<https://gist.github.com/magnars/4b1f32a76523a4b39ef8#prepopulating-the-angularjs-template-cache>Prepopulating
 
the Angular.JS template cache

optimus-angular/create-template-cache is a custom Optimus asset loader. It 
creates a virtual JavaScript asset that populates the Angular.JS template 
cache with your given templates.
<https://gist.github.com/magnars/4b1f32a76523a4b39ef8#preparing-javascript-for-minification>Preparing
 
JavaScript for minification

When minifying JavaScript, local variable names are changed to be just one 
letter. This reduces file size, but disrupts some libraries that use clever 
reflection tricks - like Angular.JS.

By transforming your assets with optimus-angular/prepare-for-minification, 
these reflection tricks are replaced by an alternate syntax that still 
functions after mangling of local names.
<https://gist.github.com/magnars/4b1f32a76523a4b39ef8#in-summary>In summary

Hopefully these examples show how Optimus is open for extension. So while 
the core of Optimus is frontend optimization, the introduction of first 
class assets open up new possibilities.

If you use Optimus or want to get started, please do let me know. I'm happy 
to address any relevant issues. My goal is for Optimus to be a really solid 
piece of software.

Thanks,

- Magnar

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to