Is there a way to selectively register a stimulus controller so it doesn't get registered on every page in Rails 7.
I have a stimulus controller stripe_controller.js that imports stripe-js:
import { loadStripe } from "@stripe/stripe-js"
and this is causing stripe to generate an iFrame on every page of my site even when the controller is not connected.
My app/javascript/controllers/index.js is loading my controller:
import { application } from "./application"
import StripeController from "./stripe_controller"
application.register("stripe", StripeController)
Is there a way to dynamically register instead of including it in the index.js file?
pin "@stripe/stripe-js", to: "https://ga.jspm.io/npm:@stripe/[email protected]/dist/stripe.esm.js"topin "@stripe/stripe-js/pure", to: "https://ga.jspm.io/npm:@stripe/[email protected]/dist/stripe.esm.js".