Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297488

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

$
0
0

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

We should have a list of attributes that support aggregation.
JS files with these attributes should be aggregated together if they have the same attribute values and we should make sure the attributes are on the bundle.
This means that if a library defines 3 JS files with the defer attribute, we should create a single bundle with the defer attribute.

Remaining tasks

User interface changes

None

API changes

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

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 297488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>