Since upgrading from D7 a6 to D7 a7 (using Head2Head's Alpha2Alpha), CSS and JS aggregation seem to have stopped working. Instead of the aggregated files, there is a long list of CSS and JS files including on all of my test site's pages. Disabling and reenabling the aggregation has no effect (though the CSS includes do look different with it on and off).

Comments

mamarley’s picture

Priority: Normal » Major
mamarley’s picture

This issue also occurs on a freshly-installed site (with nothing done to it except enabling CSS and JS aggregation).

mamarley’s picture

Version: 7.0-alpha7 » 7.x-dev
mamarley’s picture

Priority: Major » Normal
mamarley’s picture

mamarley’s picture

Here is what the CSS section looks like:

<link type="text/css" rel="stylesheet" href="http://example.com/sites/default/files/css/css_-Tia5wQl3EjzGr_gAxNT70Xo1Ww26Ersb5LiKaZu1lM.css" media="all" /> 
<link type="text/css" rel="stylesheet" href="http://example.com/modules/dhtml_menu/dhtml_menu.css?l8vzgb" media="all" /> 
<link type="text/css" rel="stylesheet" href="http://example.com/sites/default/files/css/css_nOXmgY8EQTEJyflwl9LOaUrtprcvvRZ9V7MmPN7AaaY.css" media="all" /> 
<link type="text/css" rel="stylesheet" href="http://example.com/modules/extlink/extlink.css?l8vzgb" media="all" /> 
<link type="text/css" rel="stylesheet" href="http://example.com/modules/openid/openid.css?l8vzgb" media="all" /> 
<link type="text/css" rel="stylesheet" href="http://example.com/sites/default/files/css/css_p2TFk0xBpJkdqHCVY-cmPsBs4viJCFgBGOMbnQ2-mQU.css" media="all" /> 
<link type="text/css" rel="stylesheet" href="http://example.com/sites/default/files/css/css_Hn50OtTOU2KoZ5uTB8DK05XPgY_Ug3nBKljfCipqv50.css" media="print" /> 

And the JS section:

<script type="text/javascript" src="http://example.com/misc/jquery.js?v=1.4.2"></script> 
<script type="text/javascript" src="http://example.com/misc/jquery.once.js?v=1.2"></script> 
<script type="text/javascript" src="http://example.com/sites/default/files/js/js_AvCLLatPyPT165dWXdLmpsSkcziBNgWkKj9L-WZtvww.js"></script> 
<script type="text/javascript" src="http://example.com/misc/jquery.cookie.js?v=1.0"></script> 
<script type="text/javascript" src="http://example.com/modules/dhtml_menu/dhtml_menu.js?l8vzgb"></script> 
<script type="text/javascript" src="http://example.com/sites/default/files/js/js_WrovdDdkDncy8MqOWBZZTV_NFuxBLQ0NYbucsqv6bqw.js"></script> 
<script type="text/javascript" src="http://example.com/modules/extlink/extlink.js?l8vzgb"></script> 
<script type="text/javascript" src="http://example.com/modules/openid/openid.js?l8vzgb"></script> 
stevenpatz’s picture

Latest head, I can confirm this.

munzirtaha’s picture

Subscribing

grendzy’s picture

XiaN Vizjereij’s picture

Title: CSS/JS aggregation doesn't seem to work with Drupal 7 alpha 7 » CSS/JS aggregation doesn't seem to work with Drupal 7 RC2
Priority: Normal » Major
Status: Closed (duplicate) » Active

I just installed a fresh copy of Drupal 7 RC2 and its still broken.

As #6 mentioned there is a long list of css and js files and not one combined file for each.

grendzy’s picture

Priority: Major » Normal
Status: Active » Closed (duplicate)

This is working as intended. The parameters for drupal_add_js and drupal_add_css have changed:

http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad...
http://drupal.org/update/modules/6/7#drupal_add_js_options

If there are contributed module files that are not aggregated, and you think they should be (for example extlink.js), then please file a bug with the contrib module involved. It's likely that many modules will need to update their calls to drupal_add_css/js.

XiaN Vizjereij’s picture

Title: CSS/JS aggregation doesn't seem to work with Drupal 7 RC2 » [Regression] CSS/JS aggregation doesn't seem to work with Drupal 7 RC2
Priority: Normal » Major
Status: Closed (duplicate) » Active

According to #998446: Make sure drupal_add_* are in the correct group and have preprocess enabled that is a bug in Drupal. I can also confirm that its not even working for a naked Drupal installation with just Garland enabled.

int’s picture

I can confirm, it's a drupal bug, and is a regression.

grendzy’s picture

Status: Active » Closed (works as designed)

While the answer may be difficult to accept, it's right there in the docs: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad... .

More aggregate files are expected in D7. There is no longer one giant file - instead there are 3 groups: CSS_SYSTEM, CSS_DEFAULT, and CSS_THEME. Additionally, within each group you have every_page => TRUE and every_page => FALSE. So there are 6 possible aggregate files. Additionally, different media types (such as print) also result in a different set of aggregates.

Bence’s picture

Status: Closed (works as designed) » Active

I can confirm, CSS/JS aggregation doesn't seem to work with Drupal 7 RC2.

Bence’s picture

Status: Active » Closed (works as designed)

Ok, then works as designed.

int’s picture

Status: Active » Closed (works as designed)

crosspost

grendzy’s picture

int: Yes, what you posted appears to be correct. 6 is the worst case - sometimes you'll have fewer, maybe 4 or 5, depending mostly on the number of files that have every_page => FALSE. If you want to see more detail about how things are grouped, try installing the devel module and running

dpm(drupal_add_css());

XiaN Vizjereij’s picture

Status: Closed (works as designed) » Active

Ok apparently that ... is ... working as intended .. kind of. Another change in D7 i will probably never understand. That might make sense from a core developers point of view, but for me as end user and administrator this simply adds massive I/O on my cache folder, 7 new HTTP requests per page view and more objects for the user to dl ( the parallel download problem ). I can even see some big performance issues with improperly configured ETAGS and Cache Expire headers on misconfigured shared hosts ( those would pop up on D6 as well, but would have way less impact, because there where only two big files ).

I really feel that this is an regression. Can anyone please explain why this change was made?

And maybe we can have an "Please combine all those files into one big file" checkbox under the aggregated options with a helper text that explains what issues that might bring and why you should not enable it. If there are more people feeling that this is needed i'll refill another issue as feature request ( or relabel this one ).

Bence’s picture

I am also confused, what's the problem with one big CSS and JS file? Why do we need six?

Stevel’s picture

Let's say the css being used on a website is divided in parts A-Z.
All pages need parts A-J, page 1 additionally needs part K and page 2 needs part L:

Page CSS parts needed
Page 1 A-J and K
Page 2 A-J and L

When you want to have a single css file per page request:

Page CSS parts transferred
Page 1 A-J and K
Page 2 A-J and L

So when the user visits both pages, blocks A-J need to be transferred twice.

By splitting up the aggregated css files, there is one file that contains the blocks A-J. On the first page request, two css files are needed (one containing blocks A-J and one containing block K)
On the second page request, only block L needs to be transferred, as the file containing block A-J is already in the browser, thus speeding up the overall process.

Page CSS parts transferred
Page 1 A-J and K
Page 2 L
XiaN Vizjereij’s picture

Thats what i thought the benefits would look like from the core dev's perspective. But from the users ( as of enduser and admin ) point of view it looks like :

One big file containing all css of the site

PRO : Only one file in the cache folder per session
PRO : Lesser HDD fragmentation because of only one file
PRO : Only one GZIP process is needed if gzip is enabled ( on the server's, as of the users side )
PRO : The file doesn't suffer from the browsers parallel download problem ( see here or here )
PRO : Only 2 HTTP request for javascript and css
PRO : Only two ETAGS and EXPIRE evaluations needed from the servers and browsers point of view

CON : If some small part in the css changed the user has to redownload the whole file
CON : The initial page visit requires more data to be transfered
CON : A big file may block the the parallel download of components and in the worst case mayorly delay the page load, because its a big clunky file.

Multiple small file containing parts of the site's css

PRO : The initial page load requires less data to be transfered
PRO : If chunks of the css changed only one file needs to be redownloaded

CON : 8+ HTTP requests for CSS and JS
CON : HDD defragmentation and IO load on the webserver because of a large amound of small files created and deleted in the cache folder ( that will be a massive problem for larger websites. Say hi to 8000 files in the cache folder changing every second )
CON : 8+ Gzip/ETAG/EXPIRE operations needed ( depending on how good the cache of the browser and webserver works its more on the client or server side )
CON : If a part of the js/css is significantly bigger than another parts it will block the other files from being processed by the browser. I'm fully expecting this to happen, because 98% of the drupal websites don't have a fake or real CND set up and are limited to the 2 files per schedule rule. )
CON : Will result in even more js/css files, because of wrongly implemented drupal_add_* functions. Thats not Drupal's fault, but the default PREPROCESS = FALSE wasn't a good choice. Its probably 1 out of 1000 cases where a dev that call's drupal_add_* would NOT want his code to be aggregated.

Its probably not a full list and some of the things here might just rely on proper server configuration ( which most shared hosts are not ), but ... i don't see the advantage here.

EDIT

Also see the linked page on #1000472: CSS added with @import are downloaded sequentially on IE, http://code.google.com/intl/de-DE/speed/page-speed/docs/rtt.html#Paralle... and http://code.google.com/intl/de-DE/speed/page-speed/docs/rtt.html#Combine... for more information about the points i've mentioned here. The two pictures of the last link say it all.

Stevel’s picture

You missed my point. In the case where you have only a single css file, for each page where other css is needed, a different file needs to be downloaded, so even when a second page view needs only 5 lines of extra css (which aren't in the css file for the first page because then e.g. that would look bad), the entire css needed for that page needs to be re-downloaded!
When you have multiple files, for the second page view only the additional 5 lines need to be downloaded.

damien tournoud’s picture

Status: Active » Closed (works as designed)

This is definitely by design.

CON : HDD defragmentation and IO load on the webserver because of a large amound of small files created and deleted in the cache folder ( that will be a massive problem for larger websites. Say hi to 8000 files in the cache folder changing every second )
CON : Will result in even more js/css files, because of wrongly implemented drupal_add_* functions. Thats not Drupal's fault, but the default PREPROCESS = FALSE wasn't a good choice. Its probably 1 out of 1000 cases where a dev that call's drupal_add_* would NOT want his code to be aggregated.

On the contrary. The new system can only result in less files cached and smaller ones.

indigoblue’s picture

Accepting that the way aggregation works in D7 is "by design" does not mean that it is optimal or a good solution for everyone or a good reason to mark this topic closed when clearly there is much concern around the issue.

It seems to me that the design is based on a use case that is simply not relevant for many drupal users - particularly large site developers and is a real regression from D6. For many sites, putting everything into one big file is optimal - the "a particular page needs 5 lines" argument (#24) doesn't really stand because for most site purposes simply including everything in the one file - even though many parts are not required for a particular page - is optimal where the js/css files are stable. CSS & JS are downloaded & cached once - ALL future css/js demands are now delivered from the browser cache. Of course I also accept that there are other use cases where the current model would be preferred. Eventually in either case the files will all end up in the cache. However - the current design will mean ( whether the file is in the cache or not ) that many more files must be processed and the amount of html to be processed and downloaded IS increased. I must admit I like to keep my html as clean and tight as possible and I don't think I'm alone!

If there are special cases, then it is a straight forward case to simply exclude that code from aggregation, the cost being an additional file..

As D7 stands ySlow is choking on the LACK of full aggregation. I think the idea, mentioned earlier of a checkbox that would allow FULL aggregation of all files marked for aggregation into ONE file is a very positive idea and one that would allow the designers to remain true to their vision whilst preventing a regression from D6 and allowing others who's use cases are different to have FULL aggregation. This is surely not a difficult to implement or controversial proposal?

Just my pennies worth ...

XiaN Vizjereij’s picture

Title: [Regression] CSS/JS aggregation doesn't seem to work with Drupal 7 RC2 » [Regression] Add an option for CSS/JS aggregation into a big file each
Category: bug » feature
Status: Closed (works as designed) » Active

Maybe we should go the route of a feature request then? Since most of us agree that this is an regression, i'll leave it in the title for now.

damien tournoud’s picture

Version: 7.x-dev » 8.x-dev
indigoblue’s picture

Great! I think the title change and category is right and properly describes the issue.

I fully expect others who either upgrade from D6 or start new developments with D7 to be looking at this. Maybe enough momentum can be gathered to push for a 7.x target?! ;)

tx

grendzy’s picture

Folks... you need to think about what YSlow is not showing you: how the D6 aggregation strategy impacts subsequent page loads. Once you start adding modules this becomes a real issue, even for small sites.

For a basic example, look at the plus1 module in D6: It adds a CSS and JS file on pages with a voting widget, which will "bust" the aggregate on these pages. The new strategy is a compromise with many factors. Is it optimal for everyone? Of course not, and neither was the old strategy.

The good news is there is room for a contrib module to provide more control:
http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
It would take about 5 lines of contrib code to revert to the D6 strategy, if that suits your site.

indigoblue’s picture

I agree that there will be cases where having the current D7approach may be more practical. But for many people - even in the example @grendzy gave... simply having ALL the css & js in a single file (whether it is used on a particular page or not) is more efficient. If there are modules that do not want to mark their files as suitable to be aggregated for all pages, then the price is additional files. This is a trade-off that should be under the control of the site developer as every situation will be different.

I think there is at least agreement that niether the D6 or D7 approaches are perfect for every situation - therefore the option of a choice seems a sensible way forward. I believe this should be addressed in core not contrib. D8 and either a patch or a backport to D7.x.

catch’s picture

Issue tags: +Performance

There is a Drupal 7 contrib module that does this, I have not reviewed it yet: http://drupal.org/project/core_library

More importantly, I'd like to see javascript aggregation made pluggable in D8, and this backported to D7 if we can do so without breaking bc. I had to do quite unholy things in http://drupal.org/project/agrcache to swap out the js aggregation mechanism.

owen barton’s picture

Regarding #26 - Drupal 6 did not "include everything in one big file", rather it included various combinations of almost everything so that users got a different large file on each page view - this is completely different from a performance point of view. If there was a way to generate a single (or a small number to allow for parallel downloads) file, there would be support for that, but it is simply not possible whilst we have the drupal_add_* based system for adding files (meaning there is no way to "see" all files on the site), and at the same time respecting weights, device classes, IE grouping rules etc.

wim leers’s picture

Status: Active » Closed (works as designed)

This has been a dead issue for about 2.5 years.

Also, #352951: Make JS & CSS Preprocessing Pluggable landed in Drupal 8, so in Drupal you will be able to implement this behavior easily.