Skip to content

Commit

Permalink
Lazy load iframely script (#2753)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge authored Jan 17, 2025
1 parent 29d5979 commit eac1314
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-spies-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gitbook': patch
---

Lazy load iframely script to make page more responsive
7 changes: 5 additions & 2 deletions packages/gitbook/src/components/DocumentView/Embed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as gitbookAPI from '@gitbook/api';
import { headers } from 'next/headers';
import Script from 'next/script';
import ReactDOM from 'react-dom';

Expand Down Expand Up @@ -32,7 +31,11 @@ export async function Embed(props: BlockProps<gitbookAPI.DocumentBlockEmbed>) {
}}
data-visual-test="blackout"
/>
<Script src="https://cdn.iframe.ly/embed.js" nonce={nonce} />
<Script
strategy="lazyOnload"
src="https://cdn.iframe.ly/embed.js"
nonce={nonce}
/>
</>
) : embed.type === 'integration' ? (
<IntegrationBlock
Expand Down

0 comments on commit eac1314

Please sign in to comment.