To add a js library to the header, define your library in my_module.libraries.yml
with the header: true
property.
my_library:
header: true
etc ...
Any dependencies defined for your library will always be loaded before your library whether loading your js in the header or footer.
See Asset loading order section here.