Local JavaScript and CSS files are aggregated and then compressed when:
- Their definition sets
preprocess
to true
(or 1
)
- There is more than a file in that group
Remote JavaScript and CSS files are never aggregated and compressed.
In the case of the core/modernizr library (line 1124 of the core.libraries.yml file), the library uses two files (assets/vendor/modernizr/modernizr.min.js and misc/modernizr-additional-tests.js), but preprocess
is set to 0
for both of them.
modernizr:
# Block the page from being loaded until Modernizr is initialized.
header: true
remote: https://github.com/Modernizr/Modernizr
license:
name: MIT
url: https://modernizr.com/license/
gpl-compatible: true
version: "3.11.7"
js:
assets/vendor/modernizr/modernizr.min.js: { preprocess: 0, weight: -21, minified: true }
misc/modernizr-additional-tests.js: { preprocess: 0, weight: -20 }
Implementing hook_js_alter()
, it is possible to change preprocess
to TRUE
for those files. That would let Drupal aggregate and compress those files too, but it could cause the JavaScript code not to work correctly. There must be a reason for Drupal core to set preprocess
to 0
for those files.