JS scripts not loading on certain pages When logged in as a user (not admin), some JS scripts do not load on certain pages.
I found out about this issue because I am using the module EU Cookie Compliance and the scripts it uses (eu_cookie_compliance.js, jquery.cookie.shim.js, js.cookie.min.js) aren't always loaded.
I am using a JS method provided by the EU Cookie Compliance module in my custom theme and found out it triggered an error on some pages (because the scripts aren't loaded).
For example, the scripts load on /user/2 but don't on /user/2/orders or /user/2/customer as you can see on the below image. Why does this happen?

I can see no option in EU Cookie Compliance module that prevents loading the script on some pages. Nor did I find anything in the code.

Drupal core: 8.9.3
EU Cookie Compliance: 8.x-1.9

Edit:
I have now included eu_cookie_compliance as a dependency in my theme:
dependencies:
  - core/drupal
  - core/jquery
  - core/jquery.once
  - core/drupalSettings
  - eu_cookie_compliance/eu_cookie_compliance
  - eu_cookie_compliance/eu_cookie_compliance_bare

And this fixed the fact that the scripts weren't loaded on all pages. That said, I now have errors on these specific pages.
All I do in my theme's JS (radix_sub.script.js) is using Drupal.eu_cookie_compliance.hasAgreed() which now triggers the following errors:

I have tried declaring only eu_cookie_compliance and only eu_cookie_compliance_bare and both in my theme libraries, and the errors are identical.
I don't know why it's not loading on some pages, but ultimately it's because the library isn't required for those pages. If a module's library is required by your theme then you need to declare it as a dependency.
You can do this for your library in your theme's libraries.yml file. See the Declaring dependencies documentation.
# my_theme.libraries.yml
# It's not clear if you want the bare or full cookie compliance library
my_library:
  js:
    js/my_libary.js: {}
  dependencies:
    - eu_cookie_compliance/eu_cookie_compliance
    - eu_cookie_compliance/eu_cookie_compliance_bare