0

I think I know the answer, because I tried to attach an external library like this:

{% set location = {'type': 'external'} %}
{{ attach_library('//example.com/example.js/v3/example.js', location) }}

This did not attach the desired library, am I missing something, or is this a non-starter?

1
  • I don't see the attach_library twig extension having a second parameter. Look for the implementation of the twig extension above in Drupal\Core\Template\TwigExtension.php in the function attachLibrary. What version of twig are you using? I'm in Drupal 8.2.1. Oct 30, 2016 at 1:35

1 Answer 1

4

Add external files in libraries: https://www.drupal.org/developing/api/8/assets

See the section on "CDN / externally hosted libraries".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.