Include Json file into Twig template I'm trying to run this library ParticleJS which requires me to download a Json.

I added this file into theme/libraries.yml this way:

global-js:
  js:
    assets/js/particles.min.js : {}
    assets/js/particles.json : {}


But that gives me this error:


  Refused to execute script from
  'https://www.example.com/themes/nexus/assets/js/particles.json?pem8cm'
  because its MIME type ('application/json') is not executable, and
  strict MIME type checking is enabled.


So I'm added:

&lt;script src="themes/nexus/assets/js/particles.json"&gt;&lt;/script&gt;


And it is giving me the same error.

Can someone help me with this problem, please? How should I include any other file into twig templates? Thank you
You need use hook_page_attachments_alter

function mytheme_page_attachments_alter(&amp;$attachments){
  $attachments['#attached']['html_head'][] = [
    // The data.
    [
      '#type' =&gt; 'html_tag',
      // The HTML tag to add, in this case a  tag.
      '#tag' =&gt; 'script',
      // set attributes like src to load a file
      '#attributes' =&gt; array('src' =&gt; '/themes/mytheme/assests/js/particles.json'),

    ]
  ];

}