title: Where to place Javascript used in one page only in Rails 7 with importmap
body: <p>When using Rails 7 with import maps, where do I put code that should be executed by one view only?</p>
  <p>Specifically, I have a view that needs to run some Javascript code on load.  My Javascript looks something like this:</p>
  <pre><code>import {TheController} from &quot;./TheController&quot;
  
  let controller = new TheController();
  
  document.onreadystatechange = function () {
    if (document.readyState === 'complete') {
      controller.onLoad();
    }
  };  
  </code></pre>
  <p>How do I setup the Javascript environment so that the <code>document.onreadystatechange</code> code is executed only by the desired view?  (Everything <em>almost</em> works when I put this code in a file imported by <code>application.js</code>, but then it gets executed by <em>every</em> view.)</p>
  <p>I suspect the answer is to create separate importmaps and importmap_tags; but, I can find any demonstrations of how to do that in Rails 7.</p>