In all prior versions of Drupal, the default was for JavaScript assets to be loaded in the header. JavaScript assets were able to opt in to be loaded from the footer.
This was a bad default for front-end performance. The default is now for JS assets to load in the footer. Being loaded in the header is now an opt-in choice, that is only necessary for critical UI elements that cannot be shown unless their corresponding JS has already run.
- Before
-
js-header: js: header.js: {} js-footer: js: footer.js: { scope: footer } - After
-
js-header: header: true js: header.js: {} js-footer: js: footer.js: {}I.e. you have to set the new
headerproperty on asset library definitions totrue, to indicate that the JavaScript assets in that asset library are in the critical path, and should therefore be loaded from the header.
Note that any dependencies — direct and indirect — of asset libraries marked as being in the critical path are also automatically loaded from the header, so you don't need to worry about dependencies being unavailable.