Load order of JS files Hey I have added the following libraries:

my-google-maps:
  js:
    https://maps.googleapis.com/maps/api/js?key=my_funkey_key&amp;: {type: external, weight: -400, attributes: {defer: true,async: true}}
my_other_lib:
  header: true
  js:
    js/mylib.js: { }
  dependencies:
    - core/drupal
    - core/drupalSettings


I have tried multiple ways to attach these files in a specific order(first google and then my custom js:

{{ attach_library('my_module/my-google-maps') }}
{{ attach_library('my_module/my_other_lib') }}


If it is not in the specific order the map is undefined.How can I specific the load order?
The libraries are loaded by weight, not in the order they are defined.

You already had figured that out. You have set a weight of -400 for the external library. This will be the first library loaded, because in drupal the lowest weight for a library is -22. But most times you would want to be above -20, because this is the weight of jquery, on which most libraries depend.

The problem in your case is, that the library mylib.js is specified to be loaded in head. So the external library will never be able to come ahead. It's loaded at top of all other libraries because of the low weight, but still with the bunch of all the other libraries at the end of the document.