I have followed the official documentation, but it doesn't work
global-styling:
version: VERSION
js:
js/bootstrap.min.js: {}
js/custom.js: {}
css:
component:
css/style.css: {weight: 50}
dependencies:
- core/drupalSettings
- core/jquery
- core/jquery.once
- core/drupal
- core/popperjs
- my_theme/fontawesome
fontawesome:
js-header:
header: true
js:
//kit.fontawesome.com/12345678.js: {}
This gives me error:
Drupal\Core\Asset\Exception\IncompleteLibraryDefinitionException: Incomplete library definition for definition 'fontawesome' in extension 'my_theme' in Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension() (line 131 of core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).
Please note that I wanna keep my js file in the dependencies
, I don't want to do the following:
global-styling:
version: VERSION
js-header:
header: true
js:
//kit.fontawesome.com/1234556.js: {}
fontawesome
, declared in*.libraries.yml
, and you don't have a library with that name in the code you showed us. So something's not matching up.fontawesome
library as a dependency of the library that will depend upon it. Dependencies always load first, and as pages usually load better/faster with scripts at the end of the page, it would be better to not have it in the header. That said, if there is a specific requirement to havefontawesome
load in the header specifically, Mario's solution is the way to go.