Im loading a JavaScript file via my theme's libraries.yml file. How can I change the weight of this file?

I need the file to load before the core and module's JavaScript files. If I set header: true then this happens, but I still want to load the file at the bottom of the page.


You need to try this with in libraries.yml file

    js/bar.js: { weight: N }
  • Note the the value must be in quotes.
    – Evanss
    May 25 '16 at 12:49
  • no need of quotes. Try without it.
    – vgoradiya
    May 25 '16 at 12:53
  • UnexpectedValueException: The theme/lib library defines a positive weight for 'js/bar.js'. Only negative weights are allowed (but should be avoided). Instead of a positive weight, specify accurate dependencies for this library.
    – zsd
    Sep 1 '20 at 9:43

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.