steveluscher
2011-Jun-16 18:45 UTC
HTTP Streaming: Javascript in the head or at the bottom of the page?
There''s a discussion going on at StackOverflow about whether, with the advent of HTTP streaming in Rails 3.1, it''s time to bend the rules with respect to the time honoured tradition of putting <script> tags before the closing </body> tag. http://stackoverflow.com/questions/6116436/rails-3-1-http-streaming-js-in-head-or-bottom-of-body/6376719#6376719 Cheers, Steven… -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Xavier Noria
2011-Jun-16 19:00 UTC
Re: HTTP Streaming: Javascript in the head or at the bottom of the page?
On Thu, Jun 16, 2011 at 8:45 PM, steveluscher <google-9MfpGcyKd/Me6wdzGrA1MA@public.gmane.org> wrote:> There''s a discussion going on at StackOverflow about whether, with the > advent of HTTP streaming in Rails 3.1, it''s time to bend the rules > with respect to the time honoured tradition of putting <script> tags > before the closing </body> tag. > > http://stackoverflow.com/questions/6116436/rails-3-1-http-streaming-js-in-head-or-bottom-of-body/6376719#6376719For the general case, I think unfortunately they are still going to go to the bottom. Reason is Safari for Mac buffers 1024 bytes before it starts to issue requests for assets (and Safari for iPhone and iPad buffer 512 bytes). Since the head of a document is typically smaller, Safari users would still get the ordinary bad experience. Firefox, Opera, and IE8 do not buffer, and Chrome buffers 252 bytes, according to some test I''ve done together with Hongli Lai. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Rob Biedenharn
2011-Jun-16 19:10 UTC
Re: HTTP Streaming: Javascript in the head or at the bottom of the page?
On Jun 16, 2011, at 3:00 PM, Xavier Noria wrote:> On Thu, Jun 16, 2011 at 8:45 PM, steveluscher > <google-9MfpGcyKd/Me6wdzGrA1MA@public.gmane.org> wrote: > >> There''s a discussion going on at StackOverflow about whether, with >> the >> advent of HTTP streaming in Rails 3.1, it''s time to bend the rules >> with respect to the time honoured tradition of putting <script> tags >> before the closing </body> tag. >> >> http://stackoverflow.com/questions/6116436/rails-3-1-http-streaming-js-in-head-or-bottom-of-body/6376719#6376719 > > For the general case, I think unfortunately they are still going to go > to the bottom. Reason is Safari for Mac buffers 1024 bytes before it > starts to issue requests for assets (and Safari for iPhone and iPad > buffer 512 bytes). > > Since the head of a document is typically smaller, Safari users would > still get the ordinary bad experience. > > Firefox, Opera, and IE8 do not buffer, and Chrome buffers 252 bytes, > according to some test I''ve done together with Hongli Lai. > >Has Rails changed the order in which it does things?? * instantiate a controller object and call the appropriate action method * render a view (and its partials, etc) * grab the layout and build the page by interpolating the various content_for bits and the main render content where there are yield''s * return the whole thing as the response How can you get the <head> from the layout first? What if a ''yield :head_stuff'' is encountered? -Rob P.S. I haven''t played with 3.1 yet and wasn''t at RailsConf to hear any related talks. Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Xavier Noria
2011-Jun-16 19:16 UTC
Re: HTTP Streaming: Javascript in the head or at the bottom of the page?
On Thu, Jun 16, 2011 at 9:10 PM, Rob Biedenharn <Rob-GBZH0y1GwQfnZcttdmLDtcI/UQi/AW5J@public.gmane.org> wrote:> Has Rails changed the order in which it does things?? > > * instantiate a controller object and call the appropriate action method > * render a view (and its partials, etc) > * grab the layout and build the page by interpolating the various > content_for bits and the main render content where there are yield''s > * return the whole thing as the response > > How can you get the <head> from the layout first? What if a ''yield > :head_stuff'' is encountered?That''s still how things work in general. But now you can also ask Rails to stream a certain action, or all actions of a controller. In that case, a chunked response is produced and the order of evaluation is different (think top-down). As you anticipated this has implications, see http://edgeapi.rubyonrails.org/classes/ActionController/Streaming.html -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.