> I dont know how liftAjax.js is generated, or if it changes or not,
> also I have no idea (if it regenerated) how it could be minified, and
> I know that minification seem like a micro-optimization but...
>
[...]
> So, analyzing a couple of lift apps with YSlow I find a couple of
> things that could be done to improve the average load time. Of course
> there's a lot of impact on how you do your css, where you host css and
> images(and how), compresion, server configuration, javascript and css
> performance and a lot of things on the application side; but it would
> be nice to make everything possible on the framework side to create
> that culture around every lift app =)
I've been thinking about this for some time and may get around to
implement it at some point, but it doesn't have top priority for me atm,
so I'll just share the ideas here:
There are a number of situations that revolves around this:
- Minifying JS & CSS files (gzip can be handled by the frontend I
think?)
- To minimize requests, the Expires-Date should be set way into the
future. How do we ensure client always get the right file when changing?
- Many CSS & JS files can be combined into a single file for better performance
for first time visitors (this doesn't work for all files so some kind
of exception list needs to be maintained)
- Using a CDN for distribution of static files
So to sketch the idea:
- In templates/html all requests for JS or CSS resources should be via a
lift tag, e.g: <lift:javascript src="/classpath/jquery.js"/> and
<lift:css href="/css/main.css">
- In development mode, Lift would just generate the corresponding tags
for easy debugging
- In production mode, Lift would minify the resource (and cache of
course) and generate the tags, but the MD5 sum of the file appended to
the URL. This way, we ensure that clients will always reload the
resource if it changes even if the Expires date is set into the future
- In the advanced scenario, multiple files can be combined into a single
file (i.e. all css files can be combined to a single, minified
version), all javascript files could be combined. These files should
probably be generated (and cached) dynamically since different pages
may need different resources
- If configured, the resources could be served via a CDN by just
generating the correct URL
Thoughts?
/Jeppe
I kinda knew that coz i did a very fast search for a file called
liftAjax.js... just wanted to be sure! And now I am...
Why don't you guys let me run some benchmarks before actually
investing some time on this? (but keep talking about this subject tho,
nothing bad can come from exploring how to do faster lift apps! )