I'm very curious how your Rails apps include javascript. For example:
A bit of background: I work on a massive Rails app that is very JS heavy. Currently, all js is minified and served from a single file. This makes things very convenient as all frameworks and widgets are available everywhere. I'm beginning to question this approach is it seems a bit crazy to make all users pay the price for some js that they may never see. Littering the code with script includes seems crappy and difficult as large portions of the site deliver content via ajax.
Anyone have any advice to share?
Thanks much!
There are several trade-offs to consider:
Notes
Answers to your specific questions
Do you package all your js code into a single file and serve it for all requests?
All requests get a large file of JS that has library code and JS used on most pages. Some specific pages also get an additional JS file.
do you conditionally load certain js depending on controller/action?
Yes, for a couple of very heavy JS pages, those pages get an additional JS file. All pages get the reg JS file and it is cached/available for all pages.
what tools or techniques do you use, ie: asset_packager, yui compressor, sprockets, BigPipe inspired implementation?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With