Skip to content

Commit

Permalink
Preloaders (#218)
Browse files Browse the repository at this point in the history
* Disable bfcache

* Update head.html

* test w/o recaptcha

* moved recaptcha post lcp

* Update head.html
  • Loading branch information
fnhipster authored Nov 27, 2024
1 parent 5107d3c commit d6dfdae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions head.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

<link rel="preload" href="/placeholders.json" as="fetch" crossorigin="anonymous" />
<link rel="modulepreload" href="/scripts/initializers/index.js" />
<link rel="modulepreload" href="/scripts/initializers/auth.js" />
<link rel="modulepreload" href="/scripts/initializers/cart.js" />
<link rel="modulepreload" href="/scripts/__dropins__/storefront-auth/api.js" />
<link rel="modulepreload" href="/scripts/__dropins__/tools/event-bus.js" />
<link rel="modulepreload" href="/scripts/__dropins__/tools/fetch-graphql.js" />
<link rel="modulepreload" href="/scripts/__dropins__/tools/initializer.js" />
Expand Down
12 changes: 7 additions & 5 deletions scripts/initializers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import {
} from '@dropins/tools/fetch-graphql.js';
import * as authApi from '@dropins/storefront-auth/api.js';

// Recaptcha
import * as recaptcha from '@dropins/tools/recaptcha.js';

// Libs
import { getConfigValue, getCookie } from '../configs.js';

Expand Down Expand Up @@ -52,8 +49,13 @@ export default async function initializeDropins() {
events.enableLogger(true);
// Set Fetch Endpoint (Global)
setEndpoint(await getConfigValue('commerce-core-endpoint'));
// Recaptcha
recaptcha.setConfig();

events.on('eds/lcp', async () => {
// Recaptcha
await import('@dropins/tools/recaptcha.js').then(({ setConfig }) => {
setConfig();
});
});

// Initialize Global Drop-ins
await import('./auth.js');
Expand Down

0 comments on commit d6dfdae

Please sign in to comment.