Skip to content

Commit 1107c2a

Browse files
authored
Merge pull request #723 from balibebas/trunk
perf: stop stripe scriptloader when stripe is disabled
2 parents 633d2a7 + e9a4add commit 1107c2a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pages/_document.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { ServerStyleSheet as StyledComponentSheets } from "styled-components";
44
import { ServerStyleSheets as MaterialUiServerStyleSheets } from "@material-ui/styles";
55
import favicons from "custom/favicons";
66
import theme from "custom/reactionTheme";
7-
import analyticsProviders from "../custom/analytics";
7+
import definedPaymentMethods from "custom/paymentMethods";
8+
import analyticsProviders from "custom/analytics";
89

910
/**
1011
* For details about the styled-components SSR code in this file, see https://www.styled-components.com/docs/advanced#nextjs
@@ -36,12 +37,14 @@ class HTMLDocument extends Document {
3637
...analyticsProviders.map((provider) => ({
3738
type: "text/javascript",
3839
innerHTML: provider.renderScript()
39-
})),
40-
{
41-
type: "text/javascript",
42-
src: "https://js.stripe.com/v3/"
43-
}
40+
}))
4441
];
42+
definedPaymentMethods
43+
.some((method) => method.name === "stripe_card")
44+
&& scripts.push({
45+
type: "text/javascript",
46+
src: "https://js.stripe.com/v3/"
47+
});
4548

4649
return (
4750
<Html lang="en">

0 commit comments

Comments
 (0)