How do I place my script after jQuery? How can I move the following markup after the one loading jQuery and drupalsettings?

&lt;script src="https://abc.ai/js/w?key=abc.jdnwVFfn4YUZA0in"&gt;&lt;/script&gt;


Actually, the order is the one in the following markup.

&lt;script type="application/json" data-drupal-selector="drupal-settings-json"&gt;{"path":{"baseUrl":"\/","scriptPath":null,"pathPrefix":"","currentPath":"node","currentPathIsAdmin":false,"isFront":true,"currentLanguage":"en"},"pluralDelimiter":"\u0003","ajaxTrustedUrl":{"\/search\/node":true},"user":{"uid":0,"permissionsHash":"a791675a6fdb4f639fabce88c7e91295566b58e25f936b9d181582d9321c503f"}}&lt;/script&gt;
&lt;script src="/core/assets/vendor/jquery/jquery.min.js?v=3.2.1"&gt;&lt;/script&gt;
&lt;script src="/core/misc/drupalSettingsLoader.js?v=8.5.1"&gt;&lt;/script&gt;
&lt;script src="/modules/abc/js/abc.js?v=1.x"&gt;&lt;/script&gt;


I used hook_page_bottom() to attach the script in the abc module.

function acobot_page_bottom(array &amp;$attachments) {
  $attachments['#attached']['library'][] = 'acobot/acobot-initialise';
  $attachments['acobot'][] = [
    [
      '#type' =&gt; 'html_tag',
      '#tag' =&gt; 'script',
      '#attributes' =&gt; array('src' =&gt; 'https://acobot.ai/js/w?key=' . $token),
    ],
    'acobot-token',
  ];
}


The content of the abc.libraries.yml file is the following.

abc-initialise:
  version: 1.x
  js:
    js/abc.js: {}
  dependencies:
    - core/jquery
    - core/drupalSettings


I added weight in the below code(instead of #attached in hook_page_bottom) but it does not change the position . 

function acobot_library_info_alter(&amp;$libraries, $extension) {
$libraries['acobot'] = array(
  'version' =&gt;'1.x',
  'js' =&gt; array(
     'acobot/acobot.js' =&gt; array(
        '#weight' =&gt; 100,
     ),
   'dependencies' =&gt; array(
     0 =&gt; 'core/jquery',
     1 =&gt; 'core/drupalSettings'
   )  
  ),   
);

  return $libraries;
}
The problem is that you're adding it to page bottom region, which is above the JS.

What exactly is $token, is it something personalized or is it a global license key/identifier for the whole site? If the second, then use a library alter hook to load it instead.

See https://cgit.drupalcode.org/jw_player/tree/jw_player.module#n129 for example, that dynamically alters the library definition to either load from a CDN with a dynamic url or a local path that can vary based on input from the libraries module.