Skip to main content
  • Guides & Documentation

Knowledgebase

Featured articles, how-to guides and quick tips.

Add Integrity and CrossOrigin Attributes for Libraries Theming in Drupal

If you're trying to link to an external library in your theme.libraries.yml file in Drupal, all you need to do is ensure that the correct attributes are given to the library in question.

Here's a good example:

{ type: external, attributes: { integrity: [your-integrity-code], crossorigin: [for example, anonymous] }

Just switch out the bold sections from the code above, and you're good to go.

This way, you're specifying that this library is 1) external, and 2) has the necessary attributes when rendered by Drupal.

After making any changes to the theme.libraries.yml, be sure to clear all Drupal caches in order that the changes reflect on-site.