1

I'm using drupal_add_js and drupal_add_library to add some js to my site. But when I turn on the drupal js compression, drupal is aggregating the files but it's generating 6 files and Yslow is saying that it's too much files. Is there any way to force drupal to aggregate more the files? It'd be great if drupal 7 generates only 2 or 3 files per page.

1 Answer 1

1

Surprisingly, the larger number of files can actually save bandwidth on subsequent requests, something that YSlow doesn't take into account. Aggregating everything into a single giant file is really only optimal for visitors that load a single page and no others.

I wrote an article explaining the details in Drupal 7: Taking control of CSS and JS aggregation.

To reduce the number of files, you can try the Core Library module. The article above also has some example code that will group the files together using hook_css_alter() and hook_js_alter().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.