I''m looking to get some more feedback on an issue (and fix) I posted here: https://github.com/rails/rails/issues/2294. TLDR; asset fingerprinting causes issues in production mode with certain javascript libraries due to dynamic file loading. Notably the major editors (TinyMCE, CKEditor, etc) but smaller libraries can be affected too. My fix allows for certain paths to be excluded from fingerprinting or for fingerprinting to be disabled altogether. An example; let''s say I''m building an app and I want to integrate FancyZoom (https://github.com/jnunemaker/fancy-zoom). I copy the files into my assets folders (either app/assets or vendor/assets) and require the javascript in my application.js. Everything works fine in development mode, but the images won''t load in production, due to the fingerprints appended to the image filenames. Using the image-url helpers won''t help here either - check the code (https://github.com/jnunemaker/fancy-zoom/blob/master/jquery/ js/fancyzoom.js) and you''ll see why. At this point, I am forced to move the assets into public. I either move all of the FancyZoom assets together, giving up on including the library''s javascript in my application.js, or I move only the image files into public. Either way, assets are now spread between public and app/assets. I also now have assets located at http://mysite.com/assets as well as http://mysite.com/fancyzoom. Messy. Or, if my patches are applied, I add to my config/application.rb: config.assets.fingerprinting.exclude << "fancyzoom/*" and I don''t need to do anything else. As seen in my proof of concept (https://github.com/spohlenz/tinymce-rails/blob/master/lib/tinymce- rails.rb), gems with assets can do this automatically. The app developer doesn''t need to know about it, it just works. In my opinion, this is a critical feature to make the asset pipeline workable. My fix does add some extra options to the Sprockets environment but I haven''t seen a better way of doing it yet. Thanks, Sam Pohlenz -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Aaron Patterson
2011-Aug-03 02:20 UTC
Re: Issues with asset digest fingerprinting (with fix)
On Tue, Aug 02, 2011 at 06:52:17PM -0700, Sam wrote:> I''m looking to get some more feedback on an issue (and fix) I posted > here: https://github.com/rails/rails/issues/2294. > > TLDR; asset fingerprinting causes issues in production mode with > certain javascript libraries due to dynamic file loading. Notably the > major editors (TinyMCE, CKEditor, etc) but smaller libraries can be > affected too. My fix allows for certain paths to be excluded from > fingerprinting or for fingerprinting to be disabled altogether. > > An example; let''s say I''m building an app and I want to integrate > FancyZoom (https://github.com/jnunemaker/fancy-zoom). I copy the files > into my assets folders (either app/assets or vendor/assets) and > require the javascript in my application.js. > > Everything works fine in development mode, but the images won''t load > in production, due to the fingerprints appended to the image > filenames. Using the image-url helpers won''t help here either - check > the code (https://github.com/jnunemaker/fancy-zoom/blob/master/jquery/ > js/fancyzoom.js) and you''ll see why. > > At this point, I am forced to move the assets into public. I either > move all of the FancyZoom assets together, giving up on including the > library''s javascript in my application.js, or I move only the image > files into public. > > Either way, assets are now spread between public and app/assets. I > also now have assets located at http://mysite.com/assets as well as > http://mysite.com/fancyzoom. Messy. > > Or, if my patches are applied, I add to my config/application.rb: > > config.assets.fingerprinting.exclude << "fancyzoom/*" > > and I don''t need to do anything else. As seen in my proof of concept > (https://github.com/spohlenz/tinymce-rails/blob/master/lib/tinymce- > rails.rb), gems with assets can do this automatically. The app > developer doesn''t need to know about it, it just works. > > In my opinion, this is a critical feature to make the asset pipeline > workable. My fix does add some extra options to the Sprockets > environment but I haven''t seen a better way of doing it yet.I''m not sure what to do about this issue, so I''ve assigned it to Josh. Maybe he can chime in. -- Aaron Patterson http://tenderlovemaking.com/
Great analysis! I''m using 3.2.11 and still the same problem... Looks like your solution was not accepted? Is there are any new happenings about this issue? On Wednesday, August 3, 2011 4:52:17 AM UTC+3, Sam wrote:> > I''m looking to get some more feedback on an issue (and fix) I posted > here: https://github.com/rails/rails/issues/2294. > > TLDR; asset fingerprinting causes issues in production mode with > certain javascript libraries due to dynamic file loading. Notably the > major editors (TinyMCE, CKEditor, etc) but smaller libraries can be > affected too. My fix allows for certain paths to be excluded from > fingerprinting or for fingerprinting to be disabled altogether. > > An example; let''s say I''m building an app and I want to integrate > FancyZoom (https://github.com/jnunemaker/fancy-zoom). I copy the files > into my assets folders (either app/assets or vendor/assets) and > require the javascript in my application.js. > > Everything works fine in development mode, but the images won''t load > in production, due to the fingerprints appended to the image > filenames. Using the image-url helpers won''t help here either - check > the code (https://github.com/jnunemaker/fancy-zoom/blob/master/jquery/ > js/fancyzoom.js<https://github.com/jnunemaker/fancy-zoom/blob/master/jquery/js/fancyzoom.js>) > and you''ll see why. > > At this point, I am forced to move the assets into public. I either > move all of the FancyZoom assets together, giving up on including the > library''s javascript in my application.js, or I move only the image > files into public. > > Either way, assets are now spread between public and app/assets. I > also now have assets located at http://mysite.com/assets as well as > http://mysite.com/fancyzoom. Messy. > > Or, if my patches are applied, I add to my config/application.rb: > > config.assets.fingerprinting.exclude << "fancyzoom/*" > > and I don''t need to do anything else. As seen in my proof of concept > (https://github.com/spohlenz/tinymce-rails/blob/master/lib/tinymce- > rails.rb), gems with assets can do this automatically. The app > developer doesn''t need to know about it, it just works. > > In my opinion, this is a critical feature to make the asset pipeline > workable. My fix does add some extra options to the Sprockets > environment but I haven''t seen a better way of doing it yet. > > Thanks, > Sam Pohlenz-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/Ja3mejMZ6GYJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.