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?

  • 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. – Yzmir Ramirez Oct 30 '16 at 1:35

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, privacy policy and cookie policy

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