On 29/04/07, AMA3 <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> In trying to speed up the overall download for a page, I decided to
> create a queue of Ajax.Request objects to asynchronous load a set of
> javascript files.  Due to dependencies between the files, I want to
> execute them synchronously... the only reason to use Ajax.Request is
> to download multiple scripts at once instead of waiting for one to
> complete before the next can begin downloading.
>
> Due to Ajax.Request.evalResponse(), the scripts are executing as soon
> as they are downloaded--sometimes in the wrong order.  It would be
> most helpful if there was an option to Ajax.Options to either disable
> evalResponse() or replace it with a custom method.
>
> If that's not acceptable, I'd like to know the best way to disable
> evalResponse() on a per-request basis.  I'd like a solution that
> should remain forward-compatible with future releases.
>
> I'm a big fan of Prototype and recommend it whole-heartedly in the
> Ajax class that I teach.  Without this obstacle I would love it even
> more :-)
>
> Suggestions/comments/promises greatly appreciated!

Hi.

I don't know what your server-side code is and I don't know if your JS
code is static (i.e. your server isn't generating JS code on the fly
and every request is different?).

So, say your server-side is PHP and your JS files are static (i.e.
just straight, good-old .js files), then you could get ALL the JS code
at once using a server side combining tool, combined with a caching
algorithm.

By making a single request, you can control the order in which the JS
code arrives at the client AND you get the benefit of cached data so
even less traffic.

This was raised in a SitePoint email recently and you can read about
it at 
http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files

The code is at http://rakaz.nl/projects/combine/combine.phps.

If you are not running apache, then you may not be able to use the
exact method described. Instead of using the /javascript/ or /css/
mechanism, you can call the combine.php function directly. Like I do.

<script 
src="/global/combine.php?type=javascript&files=prototype/prototype.js,script.aculo.us/scriptaculous.js,script.aculo.us/builder.js,script.aculo.us/effects.js,script.aculo.us/dragdrop.js,script.aculo.us/controls.js,script.aculo.us/slider.js,raq/raq.js,raq/additionalJS.js,raq/enhanced_date.js,raq/enhanced_element.js,raq/enhanced_event.js,raq/enhanced_math.js,raq/enhanced_string.js"
type="text/javascript"></script>

This requires no changes to the script to work and no changes to any
.htaccess file (if you are using it).

I have made a few minor changes to deal with IE6's lack of a
HTTP_ACCEPT_ENCODING header.

This is working for me on WinXPSP2 IE6/7, FF2 and O9.

Regards,

Richard Quadling


> Peace,
> AMA3
>
>
> >
>


-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to