Hotwire Discussion

How to load the Stripe JS SDK on every page?

The threads over at turbolinks/turbolinks#321 and #198 suggest to force a full reload for pages which include the Stripe JS SDK in order to avoid the error Failed to execute 'postMessage' on 'DOMWindow'. However Stripe’s documentation states:

To best leverage Stripe’s advanced fraud functionality, include this script on every page, not just the checkout page. This allows Stripe to detect suspicious behavior that may be indicative of fraud as customers browse your website.

So the SDK needs to be included on every page, but forcing a page reload on every page rather defeats the purpose of using Turbo. Are there any alternatives besides having this error appear after every single page change?

I’ve also opened issues on Stripe’s side and in the Turbo repo.