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:
<script src="themes/nexus/assets/js/particles.json"></script>
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
<script>
tags are just for loading scripts, you can't source a JSON file that way. Even if you could, what would you expect to happen? How would the browser know what you intended to do with the loaded object? You'll need to either pre-build the JS file with the object already in it, or load it via AJAX and manipulate it that way