Apostrophe Minification Behavior

8 views
Skip to first unread message

Jeremy Kauffman

unread,
Dec 14, 2010, 3:26:35 PM12/14/10
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?

Tom Boutell

unread,
Dec 14, 2010, 4:16:48 PM12/14/10
to apostr...@googlegroups.com
We don't use many non-global assets. So far we don't have any cases of
200K JS applications that are only in 1% of the pages, for instance.
Others might of course.

Putting the non-global assets in a group by using options is not a
terrible idea at all and I would be interested to hear how that works
out.

We're open to some kind of more explicit grouping.

--
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

Christopher Baker

unread,
Dec 14, 2010, 4:45:33 PM12/14/10
to apostr...@googlegroups.com

Some sort of way to disable grouping would work too. Ie: any assets included while it was disabled would be included as is. These functions could then be added to the beginning and end if the action, or the pre and post functions of the module, our create a new base action file that extends the apostrophe one and switch it to this when your address should be left alone. Did that make sense?

Jeremy Kauffman

unread,
Dec 14, 2010, 6:15:44 PM12/14/10
to apostrophenow
Tom, I'd gladly submit a patch to add some more support for this if
you guys will take it.

Tom Boutell

unread,
Dec 14, 2010, 10:11:26 PM12/14/10
to apostr...@googlegroups.com
Sure! just try to keep it simple and optional
Reply all
Reply to author
Forward
0 new messages