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! Peace, AMA3 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I think you''ll get minimal performance gains due to the 2-http-connection-per-browser-instance thing as specified in the w3c spec. You''ll only get 2 scripts downloading at a time. I suppose you could spread it against multiple subdomains which gets around the limit. As for your actual question, I can''t speak for core but it seems like a fairly minimal modification to make. Patch for adding extra option to disable evalScripts on Ajax.Request in 1.5.1_rc4 986 += , 987 + skipEvalResponse: false 1120 + if(!this.options[''skipEvalResponse'']) I tried to test it but I confess I haven''t played around with returning script blocks in content and thus wasn''t able to figure out what I needed to set on the header. Gareth On 4/30/07, AMA3 <ajax-ZySxq06A3qc@public.gmane.org> 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! > > Peace, > AMA3 > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 29/04/07, AMA3 <ajax-ZySxq06A3qc@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 30/04/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 29/04/07, AMA3 <ajax-ZySxq06A3qc@public.gmane.org> 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 > >As a guide, I''m getting around 16000 hits on this script a day. In my environment, they are nearly all FF2 or IE7. Maybe 1% are IE6. For IE6, there is no compression, so this script has a 193K payload. With compression it is 45K. So, prior to using combine, I would be pushing around 3GB of JS files a day! Now, I''m not. As the code hasn''t changed and the cache is just saying "Nothing changed". You can''t get much faster than that really! The script also supports CSS files. In theory, you could even use it to supply static HTML via AJAX but you''d have to play with it a bit (not a huge amount though). Anyway, this technique is probably going to give you the biggest return on time/investment.> > 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!" >-- ----- 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, Gareth and Richard for the helpful comments/suggestions. Additional ideas are still welcome. :) Peace, AMA3 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---