Closed skippy closed 14 years ago
Hey Skippy.
The idea with Jammit packages is that you can grab whole directories worth of files with globs, avoiding the need to merge separate packages. So in your case, I'd imagine assets.yml
would look something like this:
javascripts:
core:
- public/javascripts/defaults/*
- public/javascripts/auth/*
- ... and so on ...
Then, in your page, you'd include the common cached "core" asset package, and make a separate request for whatever page-specific JS you keep separate. That said, if the page-specific JS is small enough, it might make sense to keep all of them in the asset package, so that it's already loaded at all times.
If, currently, you're including different mixtures of :defaults, :auth, etc, on different pages, and using :cache => true
, then you're causing all of the common packages to be re-downloaded multiple times, which probably isn't what you want to be doing.
Let me know if that didn't answer your question.
Cheers, -- Jeremy
Hi Jeremy,
thank you for your response. You are absolutely correct and those are great suggestions. thanks for taking the time, Adam
hey,
I organize my files with a few default groupings (:defaults, :auth, etc) and then mix those on a page-by-page basis with some custom javascript. using :cache => true merges all these files together in production so there is only one include.
Jammit doesn't use that flag, so if I call include_javascripts(:defaults, :my_page), it will use two script tags, and two tcp connections.
I guess I should stop and ask if it's possible to combine the files in the assets.yml file? I would like to avoid setting up packages that contain mostly duplicate files. If it isn't possible do to in the assets.yml file, would it be possible to add a :cache => file_name to the *_include_tag? File_name could be something like tags.flatten.hash.to_s, to make it unique.
Thanks
I know that if I put all assets into a package in the assets.yml file, that this functionality won't
javascript_include_tag