Quantcast
Viewing all articles
Browse latest Browse all 296414

JS aggregation should account for "defer" and "async" attributes

Problem/Motivation

HTML5 proposes/solidifies asynchronous loading of JavaScript files based on two attributes: defer and async. Drupal has supported defer since at least D6, and support for async is currently in the works (#1140356: Add async, onload property to script tags).

Current behavior (as of 8.6) is that scripts with the defer attribute do not ever get aggregated (even in the case where there are multiple scripts added through one library).

Proposed resolution

Presumably, something will be added to drupal_group_js that groups "async" values with one another and "defer" values with one another, respecting their weights.

Remaining tasks

User interface changes

None

API changes

Though this affects JavaScript aggregation, this should have little-to-no API impact.


Viewing all articles
Browse latest Browse all 296414

Trending Articles