title: Is there anyway to detect a variant change in Shopify using an external Javascript/jquery file?
body: <p>I have written an external JS script that shows a custom text on the stores product's page. Currently the JS function is called once, on the window.onload function.</p>
  <p>I want my script to be able to detect a variant change and swap out the text to a different one, whenever a different variant is selected. How do I detect a variant change and get it's price in an external JS file, using only JS/jQuery function.</p>
  <pre><code>
  &lt;script id=&quot;testscript&quot; src=&quot;https://example.com/test.js?amount=${{ product.price | divided_by: 100.00 | round: 2 }}&quot;&gt;&lt;/script&gt;
  &lt;div id=&quot;mydiv&quot;&gt;&lt;/div&gt;
  
  My code in test.js:
  window.onload = function () {
      document.getElementById(&quot;mydiv&quot;).innerHTML += (&quot;&lt;p&gt;This is a test.&lt;/p&gt;&quot;);
  };
  </code></pre>