title: Include Javascript inside JS file
body: <p>How can we include javascript link inside <code>.js</code> file?. <code>.js</code> file support include, require or import like CSS or PHP?</p>
  <p>My Code :</p>
  <pre><code>// Global site tag (gtag.js) - Google Analytics
  
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://www.googletagmanager.com/gtag/js?id=UA-51600743-15';
  document.body.appendChild(script);
  
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
  
    gtag('config', 'UA-51600743-15');
  
  
  // Microsoft Clarity
  
      (function(c,l,a,r,i,t,y){
          c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
          t=l.createElement(r);t.async=1;t.src=&quot;https://www.clarity.ms/tag/&quot;+i;
          y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
      })(window, document, &quot;clarity&quot;, &quot;script&quot;, &quot;9zvbjor3bn&quot;);
  
  
  
  //Start of Tawk.to Script
  
  var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
  (function(){
  var s1=document.createElement(&quot;script&quot;),s0=document.getElementsByTagName(&quot;script&quot;)[0];
  s1.async=true;
  s1.src='https://embed.tawk.to/61d019a4c82c976b71c45176/1foae8bkm';
  s1.charset='UTF-8';
  s1.setAttribute('crossorigin','*');
  s0.parentNode.insertBefore(s1,s0);
  })();
  </code></pre>
  <p>I am trying to add all tracking code inside one file <code>analytic.js</code> and adding that to my website so it will be easy for me to maintain in future, so i do not need to edit in every page whenever any changes required in tracking codes.</p>
  <p>What is the correct way to include another js file inside js file?</p>
  <pre><code>async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-51600743-15&quot;;
  //OR
  require(&quot;https://www.googletagmanager.com/gtag/js?id=UA-51600743-15&quot;};
  //OR
  import from &quot;https://www.googletagmanager.com/gtag/js?id=UA-51600743-15&quot;;
  //Or any other way?
  </code></pre>