Hi,

Matt Winward wrote:
> Hi all.
> 
> We've just started using Scriptaculous to allow the user to rearrange
> their home page content panels. At the moment we have two unordered
> lists (left and right) and the user can move panels around to suit
> their preference.
> 
> This is working great and the only problem we have with it is that
> scriptaculous.js + prototype.js + dragdrop.js + effects.js = 192kb.
> That's after I stopped it from loading other js files like sound.js,
> for example.

Have you tried to consolidate all the files into one big file, then 
gzip it?
This order works for me:
  prototype.js
  scriptaculous.js
  builder.js
  effects.js
  controls.js
  dragdrop.js
  slider.js
  sound.js
  my-company-internal-script.js

You can also use jsmin to minimize the output file and compress it 
with gzip.
This would reduce the script download size to some tens of KB and also 
all the script is served with *one* single HTTP request instead of nine.

For example, we have a total output script of 381327 bytes (it has 
much additional code in addition to prototype and scriptacoulous).
After minification it weights 257390 bytes (67%).
After compresion it is only 63135 bytes, so its only 16% of the 
original size.

Now you have:
allScripts-minified.js
allScripts-minified.js.gz

Then, take the name of the output file, both gzipped and minified and 
append the prototype, scriptacoulous and your own script versions, so 
when you change something in scripts, you have new name.

allScripts-minified-proto-1.6.3-scripty-1.8.1-internal-r3410.js
allScripts-minified-proto-1.6.3-scripty-1.8.1-internal-r3410.js.gz

At the end, set your http server to set Expire: header to something in 
2020 year, and serve the gziped file to clients who supports it (you 
can also gzip it on the fly with proper settings of server)

Once your visitor downloaded the script, he/she will not have do it 
again until you changed versions, or until the cache is cleared.

On the other hand, if your script have some bug, which needs to be 
corrected fast, you just need to generate new file and chage it's 
version, then change links in your website accrodingly. Each visitor 
now downloads new script and do not need to refresh the page to get 
corrected, bug-free scripts.

All this without modification of scriptacoulous, so, when new version 
comes out, you just recreate the compilation and compress it, without 
complicated analysis what can be thrown out.

> 
> Seeing as all I'm using (literally) is Sortable.create(list,
> properties) twice at the bottom of the page, and nothing else, there
> must be loads that I can carve out of the js files? Ideally I was
> hoping to be able to normalise them all into one efficient js file
> that handles the Sortable business.
> 

I think modification of libraries requires to much maintenance to do 
it every time new version comes out. Better to optimize the download, 
which can and should be automated.

Regards,
SWilk

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to