That discussion aside, you can still argue that requiring all the files explicitly instead of implicitly is a win. Then you have an opportunity to think if a file should or not go into a specific manifest.
Also, it makes it easier to understand which files are loaded and in which order. Best, Luis Zamith > On 31 Oct 2014, at 12:43, Brian Underwood <public@brian-underwood.codes> > wrote: > > For sure, but it would be a relatively small file, wouldn't it? There's a > lot of (reasonable) concern about making multiple HTTP requests, but that's > usually when you're evaluating the performance of a single page. As you go > between pages you'd be just loading what you need. > > Honestly it might require some benchmarking of various apps to compare > javascript rendering performance vs HTTP request speed. Also that varies a > lot from browser to browser and network to network. Maybe somebody who's > been through this before can speak up? ;) > > Also memory usage and performance due to lots of event handlers should be > considered as your application's set of javascript files grows. > > Brian > ;p > >> On Friday, October 31, 2014 6:23:38 PM UTC+1, Geoff Harcourt wrote: >> Brian, >> >> I think require_tree often leads to problems (it’s one of the first things I >> remove when I’m building an app), but by loading specific JS files per page, >> aren’t you denying your users’ browsers the opportunity to cache the JS from >> other page visits? Separate per-page JavaScript files means your user has to >> download new script assets each time they visit a page related to a >> controller they haven’t visited before. >> >> -Geoff >>> On Friday, October 31, 2014 at 13:07, Brian Underwood wrote: >>> >>> I posted an issue about this ( >>> https://github.com/rails/rails/issues/17457#issuecomment-61292491 ) but >>> I'll copy/paste here for discussion convenience: >>> >>> >>> I feel like I'm the boy telling the emperor he has no clothes, but here >>> goes... >>> >>> Every large rails project that I've worked on has had it's application >>> javascript grow and grow because everybody leaves 'require_tree .' in >>> application.js. Personally I hate it and remove it whenever I can (it's >>> harder on legacy projects), but we should be loading javascript in a saner, >>> more modular way. >>> >>> Very often I automagically include javascript files for controllers and >>> actions if they exist. Here's an example of a helper that I've recently >>> written (it's not neccessarily pretty, but you get the idea: >>> >>> def action_and_controller_javascript_include_tag >>> capture do >>> concat javascript_include_tag controller_name if >>> Rails.root.join("app/assets/javascripts/#{controller_name}.coffee").exist? >>> concat javascript_include_tag "#{controller_name}/#{action_name}" if >>> Rails.root.join("app/assets/javascripts/#{controller_name}/#{action_name}.coffee").exist? >>> end >>> end >>> I'd be fine if that were a gem, though rails already generates controller >>> js files so it might make sense still. >>> >>> But seriously, can we please encourage not loading all of the javascript >>> for the entire application? >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Ruby on Rails: Core" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to rubyonrails-co...@googlegroups.com. >>> To post to this group, send email to rubyonra...@googlegroups.com. >>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.