@paypal/checkout-components 5.0.252-alpha.0 → 5.0.252-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.252-alpha.0",
3
+ "version": "5.0.252-alpha.2",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -103,7 +103,7 @@
103
103
  "@paypal/funding-components": "^1.0.30",
104
104
  "@paypal/sdk-client": "^4.0.166",
105
105
  "@paypal/sdk-constants": "^1.0.127",
106
- "@paypal/sdk-logos": "^2.2.0-alpha.1"
106
+ "@paypal/sdk-logos": "^2.2.1"
107
107
  },
108
108
  "lint-staged": {
109
109
  "*.sh": "prettier --write"
@@ -7,6 +7,7 @@ import { Fragment, node } from '@krakenjs/jsx-pragmatic/src';
7
7
  import { BUTTON_LAYOUT } from '../../constants';
8
8
  import { DEFAULT_APM_FUNDING_CONFIG, type FundingSourceConfig, BasicLabel } from '../common';
9
9
  import { Text, Space } from '../../ui/text';
10
+ import { getLogoCDNExperiment } from '../../lib/getLogoCDNExperiment';
10
11
 
11
12
  export function getIdealConfig() : FundingSourceConfig {
12
13
  return {
@@ -18,7 +19,16 @@ export function getIdealConfig() : FundingSourceConfig {
18
19
  BUTTON_LAYOUT.VERTICAL
19
20
  ],
20
21
 
21
- Logo: ({ logoColor, optional }) => IdealLogo({ logoColor, optional }),
22
+ Logo: ({ logoColor, optional }) => {
23
+ if (__WEB__) {
24
+ const logoCDNExperiment = getLogoCDNExperiment();
25
+ const loadFromCDN = logoCDNExperiment.isEnabled()
26
+
27
+ return IdealLogo({ logoColor, optional, loadFromCDN })
28
+ }
29
+
30
+ return IdealLogo({ logoColor, optional })
31
+ },
22
32
 
23
33
  Label: ({ logo, ...opts }) => {
24
34
  if (__WEB__) {
@@ -0,0 +1,12 @@
1
+ /* @flow */
2
+
3
+ import { createExperiment } from "@paypal/sdk-client/src";
4
+ import type { Experiment } from "@krakenjs/belter/src";
5
+
6
+ export function getLogoCDNExperiment(): Experiment {
7
+ return createExperiment("enable_logo_cdn", 100);
8
+ }
9
+
10
+ export function getPrefetchCDNExperiment(): Experiment {
11
+ return createExperiment("enable_prefetch_cdn", 50);
12
+ }
@@ -13,6 +13,7 @@ import { DEFAULT_POPUP_SIZE } from '../checkout';
13
13
  import { EXPERIENCE } from '../../constants';
14
14
  import { Buttons } from '../../ui';
15
15
  import { type ButtonProps } from '../../ui/buttons/props';
16
+ import { getPrefetchCDNExperiment } from '../../lib/getLogoCDNExperiment';
16
17
 
17
18
  type PrerenderedButtonsProps = {|
18
19
  nonce : ?string,
@@ -24,8 +25,22 @@ type PrerenderedButtonsProps = {|
24
25
  |}) => void
25
26
  |};
26
27
 
28
+ function prefetchImage(src: string): void {
29
+ const link = document.createElement("link");
30
+ link.rel = "prefetch";
31
+ link.as = "image";
32
+ link.href = src;
33
+ document.head?.append(link);
34
+ }
35
+
27
36
  export function PrerenderedButtons({ nonce, onRenderCheckout, props } : PrerenderedButtonsProps) : ChildType {
28
37
  let win;
38
+
39
+ if (getPrefetchCDNExperiment().isEnabled()) {
40
+ prefetchImage('https://www.paypalobjects.com/js-sdk-logos/2.1.1/ideal-default.svg'
41
+ )
42
+ }
43
+
29
44
  const handleClick = (
30
45
  // eslint-disable-next-line no-undef
31
46
  event : SyntheticInputEvent<HTMLInputElement>,