Postponed
Project:
Drupal core
Version:
main
Component:
asset library system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Aug 2024 at 23:52 UTC
Updated:
12 Sep 2026 at 07:10 UTC
Jump to comment: Most recent
#1945262: Introduce "before" and "after" for conditional ordering in library definitions fixes core libraries so that they no longer depend on individual file weights, but instead on declaring correct dependencies between each other.
The next step is to deprecate weight support in the assets API.
For JavaScript we should be able to just issue a deprecation message and then remove support.
For CSS, 'weight' and 'group' are conflated, see:
LibraryDiscoveryParser.php
foreach ($library[$type] as $category => $files) {
$category_weight = 'CSS_' . strtoupper($category);
assert(defined($category_weight), 'Invalid CSS category: ' . $category . '. See https://www.drupal.org/node/2274843.');
foreach ($files as $source => $options) {
if (!isset($options['weight'])) {
$options['weight'] = 0;
}
// Apply the corresponding weight defined by CSS_* constants.
$options['weight'] += constant($category_weight);
$library[$type][$source] = $options;
So that is going to need a bit more thought.
There is also #1924522: Remove separate CSS_AGGREGATE_THEME aggregate file to consider.
Comments
Comment #3
catchWe can deprecate per-file weights without resolving the CSS group issue, just won't be able to remove the weight concept entirely from the asset system, but that can be another follow-up once this is done. For example we could sort directly by the CSS group constants rather than converting them to weights.
Comment #4
catchComment #5
catchComment #6
catchI think we can do the actual deprecation here once we've removed weights in the child issues.