Skip to content

Instantly share code, notes, and snippets.

@johntran
Created July 26, 2016 17:47
Show Gist options
  • Save johntran/0fb3a9185bc3fc96c8d9d43f064fb41e to your computer and use it in GitHub Desktop.
Save johntran/0fb3a9185bc3fc96c8d9d43f064fb41e to your computer and use it in GitHub Desktop.
Lazy Loading JavaScript files in React
import makeAsyncScriptLoader from 'react-async-script';
const BillingInformationForm = () => (<div>Stripe!</div>)
export const BillingInformationFormAsync = makeAsyncScriptLoader(BillingInformationForm, 'https://js.stripe.com/v2/', {
globalName: 'Stripe',
callbackName: 'stripeCallBack',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment