How to attach external library in twig file with parameters? I have below code to share on LINE messenger

&lt;div class="line-it-button" data-lang="en" data-type="share-b" data-url="{{ current_path }}" style="display: none;"&gt;&lt;/div&gt;
&lt;script src="https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js" async="async" defer="defer"&gt;&lt;/script&gt;


How to include JS using attach_library?

{{ attach_library('https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js') }}


How to attach async="async" defer="defer" ?

Tried using

{{ attach_library('https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js', { 'async' : 'async', 'defer' : 'defer'}) }}


But not working :(
In your theme.libraries.yml file add below lines

theme.social:
  js:
    'https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js' : { external: true, defer: true, async: true }


In your twig file

{{ attach_library('theme.social') }}


Clear cache &amp; it works :)