mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
🎨 Optimized loading stripe scripts only when it is needed (#11499)
closes #11463 - Ghost used to always load stripe.js into the frontend of all pages when memberships are enabled, even when Stripe isn't configured / memberships to a page are free. This changes Ghost's behaviour to only load stripe.js when both stripe API tokens are present & not empty (the quickest way to verify that Stripe is fully configured & operational on a blog). - Needs a follow-up cleanup removing confusing/not functional `isPaymentConfigured` method from members service
This commit is contained in:
parent
8624587fb0
commit
0030acf5a6
@ -44,10 +44,17 @@ function finaliseStructuredData(metaData) {
|
||||
}
|
||||
|
||||
function getMembersHelper() {
|
||||
return `
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script defer src="${getAssetUrl('public/members.js')}"></script>
|
||||
`;
|
||||
const stripePaymentProcessor = settingsCache.get('members_subscription_settings').paymentProcessors.find(
|
||||
paymentProcessor => paymentProcessor.adapter === 'stripe'
|
||||
);
|
||||
const stripeSecretToken = stripePaymentProcessor.config.secret_token;
|
||||
const stripePublicToken = stripePaymentProcessor.config.public_token;
|
||||
|
||||
var membersHelper = `<script defer src="${getAssetUrl('public/members.js')}"></script>`;
|
||||
if (!!stripeSecretToken && stripeSecretToken !== '' && !!stripePublicToken && stripePublicToken !== '') {
|
||||
membersHelper += '<script src="https://js.stripe.com/v3/"></script>';
|
||||
}
|
||||
return membersHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user