Jeremy Kauffman
unread,Dec 14, 2010, 3:26:35 PM12/14/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to apostrophenow
I recently turned on Apostrophe's minified for the first time and
found the behavior a little curious.
The minifier groups assets based on the options provided when that
asset was included. Since most assets are included without options,
(e.g. a plain use_stylesheet call), this means that all files go into
the same group.
This causes no issues when all assets for a site are global, but as
soon as pages start including non-global assets, a completely new
group is created for the assets on that page. If a lot of your pages
contain assets local to the page or module, the end result of this
design could be even worse than no minification, as the same global
CSS/JS gets included again and again on different pages. Let me give
an example:
aHelper includes JS files: global1, global2, global3
shop/edit includes JS files: shop_edit
shop/show includes JS files: show_show
shop/edit and shop/show would each include a single, different
javascript that includes global1, 2, and 3. This would happen for any
page that includes any other javascripts at all.
If this is an issue, fortunately, it seems the problem (grouping by
options) could also be the solution. If I wanted the non-global assets
on a page to be in a separate minification group, I can simply pass in
an option, like this:
use_stylesheet('module/local', '', array('group' => 'local'))
However, I would then have to do this to any and every asset inclusion
that I don't want tainting the default "global" group. Instead, a
better option might be to put all of the global assets into their own
group. This is possible, but requires overwriting aTools.
I'm posing this here rather than filing a ticket because:
- I figure there's a decent chance I'm missing something entirely,
and this isn't an issue
- I wanted to know if others have experienced this issue
- I wanted to know if P'unk Ave has considered this behavior. Do you
guys consider it an issue? Do you guys simply not use very many non-
global assets?
- I wanted to know what you guys thought of my proposed solution. Is
it hackish to be using an option that doesn't really do anything?