Speeding load time; liftAjax.js and other javascript minified?

111 views
Skip to first unread message

DFectuoso

unread,
Jul 10, 2009, 4:00:56 AM7/10/09
to Lift
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...

"With just GZipping and Javascript minification working together, the
load time dropped from 16 seconds to just under 10 seconds. I was
absolutely extactic at the progress I was making so for and so was my
client!"
http://www.site-reference.com/articles/Website-Development/YSlow-Helping-slow-web-pages-load-faster.html

"For Google an increase in page load time from 0.4 second to 0.9
seconds decreased traffic and ad revenues by 20%. For Amazon every 100
ms increase in load times decreased sales with 1%."
http://www.svennerberg.com/2008/12/page-load-times-vs-conversion-rates/

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 =)

So I wanted to throw that idea here and see how to help in this
matter.

Ideas?

marius d.

unread,
Jul 10, 2009, 4:12:36 AM7/10/09
to Lift
liftAjax is dynamically generated and it does not represent static
content. Please see ScriptRenderer.scala. However is is a pretty small
script so I'm not sure how much we'll actually fain by minifying it.
Can you run a benchmark? Take from the browser the generated script,
minify it and the serve it statically to browser and see how much are
we saving.


Br's,
Marius

On Jul 10, 11:00 am, DFectuoso <santiago1...@gmail.com> wrote:
> 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...
>
> "With just GZipping and Javascript minification working together, the
> load time dropped from 16 seconds to just under 10 seconds. I was
> absolutely extactic at the progress I was making so for and so was my
> client!"http://www.site-reference.com/articles/Website-Development/YSlow-Help...

Timothy Perrett

unread,
Jul 10, 2009, 4:26:04 AM7/10/09
to Lift
Hey,

liftAjax.js is not regenerated dynamically as far as im aware... By
default, lift ships with the maven plugin for YUI compressor, so that
should minify the CSS/JS in your webapp dir.

Perhaps we should try and minify liftAjax.js during the build of
lift... marius is probally the best man for this as this stuff is
pretty much his baby.

Cheers, Tim

On Jul 10, 9:00 am, DFectuoso <santiago1...@gmail.com> wrote:
> 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...
>
> "With just GZipping and Javascript minification working together, the
> load time dropped from 16 seconds to just under 10 seconds. I was
> absolutely extactic at the progress I was making so for and so was my
> client!"http://www.site-reference.com/articles/Website-Development/YSlow-Help...

marius d.

unread,
Jul 10, 2009, 4:33:18 AM7/10/09
to Lift
Tim, sorry but I have to say that liftAjax.js IS generated dynamically
as I stated above :). It is not a script sitting somewhere but it
ultimately comes from ScriptRenderer.scala

Br's,
Marius

Timothy Perrett

unread,
Jul 10, 2009, 4:51:51 AM7/10/09
to Lift
My bad marius... your reply must have gone in just before mine (I
didnt read it before sending mine!)

Cheers, Tim

Jeppe Nejsum Madsen

unread,
Jul 10, 2009, 5:10:48 AM7/10/09
to lif...@googlegroups.com
DFectuoso <santia...@gmail.com> writes:

> 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

DFectuoso

unread,
Jul 10, 2009, 5:06:01 AM7/10/09
to Lift
Ok, i got my tools ready; but I am too tired so i'll run them
tomorrow...
Right now i did 2 different minifications on dfectuoso.com/liftAjax/
test1.html and test2.html in test.html its the liftAjax file we all
use... so, im probably going to run a couple hundred hits on each one
and see if theres any change; but im going to use (on each one)
diferent versions of jQuery, just cause i love statistics...

I'll keep you guys updated

DFectuoso

unread,
Jul 10, 2009, 4:47:15 AM7/10/09
to Lift
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! )

marius d.

unread,
Jul 10, 2009, 5:14:34 AM7/10/09
to Lift


On Jul 10, 11:47 am, DFectuoso <santiago1...@gmail.com> wrote:
> 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?

Who says we don't ? :) ... knock yourself out ! ... and please let us
know the outcome.

David Pollak

unread,
Jul 10, 2009, 9:43:33 AM7/10/09
to lif...@googlegroups.com
On Fri, Jul 10, 2009 at 1:47 AM, DFectuoso <santia...@gmail.com> wrote:

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! )

Premature Optimization leads to a lot of bad results.

In general, we will get to the best results when we focus on actual issues that we're facing in our running applications.  I'm all for solving a real world problem.  If you've got an app that's loading slowly because of some Lift dependency, create a benchmark and we'll work on it and make it load as fast as is possible.  But supposition about a particular piece of the Lift machinery without benchmark and without real-world need detracts from the list of real-world problems that others are facing.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
Reply all
Reply to author
Forward
0 new messages