Can stripe.js be deferred and used with some ready - callback that i can't find in the docs?
This is what i wanna do:
<script src="https://js.stripe.com/v2/" async></script>
And then in my app:
function stripeReadyHandler () {
//do stuff
}
Turns out, there's a standards compliant way to do this:
<script src="https://js.stripe.com/v2/" async onload="stripeReadyHandler()"></script>
and then:
function stripeReadyHandler () {
//this will definitely do stuff ( if you're above IE9 of course
}
Or, with JavaScript:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://js.stripe.com/v2/';
document.body.appendChild(script);
script.onload = function() {
Stripe.setPublishableKey(publishableKey);
// do stuff
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With