Answers.Body: <p>You can set the CP asset as depency then it will be loaded after it</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% do view.registerJsFile("&lt;CDN_URL&gt;",{
      depends: 'craft\\web\\assets\\cp\\CpAsset',
      position:3
  }) %}
  </code></pre>
  
  <p>That's because Yii2 will always register Bundles without any dependencies first / in the order they are defined. If you require the <code>CpAsset</code> it will be loaded afterwards</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-07T14:56:20.343Z
Answers.LastActivityDate: 2019-03-07T14:56:20.343Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I would like to add my own external JS sources at the very end of the body tag in the Craft control panel.</p>
  
  <p>I've already tried using:</p>
  
  <pre><code>{% do view.registerJsFile("&lt;CDN_URL&gt;", {position:3}) %}
  </code></pre>
  
  <p>according to <a href="https://www.yiiframework.com/doc/api/2.0/yii-web-view#registerJsFile()-detail" rel="nofollow noreferrer">https://www.yiiframework.com/doc/api/2.0/yii-web-view#registerJsFile()-detail</a>, but Craft is always adding its own JS sources after mine.</p>
  
  <p>Any help would be appreciated!</p>
  
Tags: <templating><craft3><includejs>
Title: Register JS files at the end of the body tag in the Control Panel
ThreadText: # Register JS files at the end of the body tag in the Control Panel
  
  (Asked by: username_0 on 2019-03-07)
  
  I would like to add my own external JS sources at the very end of the body tag in the Craft control panel.
  
  I've already tried using:
  
  ```
  {% do view.registerJsFile("<CDN_URL>", {position:3}) %}
  
  ```
  
  according to <https://www.yiiframework.com/doc/api/2.0/yii-web-view#registerJsFile()-detail>, but Craft is always adding its own JS sources after mine.
  
  Any help would be appreciated!
  
  **Tags:** templating, craft3, includejs
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-07. Score: 4 | Accepted answer
  
  You can set the CP asset as depency then it will be loaded after it
  
  ```twig
  {% do view.registerJsFile("<CDN_URL>",{
      depends: 'craft\\web\\assets\\cp\\CpAsset',
      position:3
  }) %}
  
  ```
  
  That's because Yii2 will always register Bundles without any dependencies first / in the order they are defined. If you require the `CpAsset` it will be loaded afterwards
  
  
  ---
  
  