title: How does the script_loader_tag function works?
body: <p>I have seen script_loader_tag function applied in functions.php, WordPress, but I struggle to understand completely how does it work.</p>
  
  <p>For example, I've seen examples like this: </p>
  
  <pre><code>function add_async_defer($tag, $handle) {
  
      if('googlemaps' !== $handle) {
          return $tag;
      }
      return str_replace(' src', 'async="async" defer="defer" src', $tag);
  }
  add_filter('script_loader_tag', 'add_async_defer', 10, 2);
  </code></pre>
  
  <p>and it is used to generate the script tag for Google Maps API:</p>
  
  <pre><code>&lt;script type='text/javascript'async="async" defer="defer" src='https://maps.googleapis.com/maps/api/js?key=AIzaSyBz02VRxO_dgaKsBS62TLL6AW4McNTQiKU&amp;#048;callback=initMap&amp;#038;ver=5.2.1'&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But what does the $tag and $handle parameters mean?</p>
  
  <p>What does numbers 10 and 2 mean in the end of the add_filter?</p>
  
  <p>Can this function be modified to display the  tag conditionally only in the specific pages?</p>