Skip to content

Commit

Permalink
fix(Script): allow passing defer=false to Script component (#34850)
Browse files Browse the repository at this point in the history
## Bug

```jsx
<Script
  async
  defer={false}
  strategy='beforeInteractive'
  src='https://securepubads.g.doubleclick.net/tag/js/gpt.js'
/>
```

output:

```html
<script src="https://securepubads.g.doubleclick.net/tag/js/gpt.js" async="" defer="" data-nscript="beforeInteractive"></script>
```

The `defer` prop is overridden by `!disableOptimizedLoading`, so can't disable it on the particular script.
  • Loading branch information
chentsulin committed Mar 11, 2022
1 parent 9145565 commit bc0816f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/pages/_document.tsx
Expand Up @@ -81,7 +81,7 @@ function getPreNextScripts(context: HtmlProps, props: OriginProps) {
<script
{...scriptProps}
key={scriptProps.src || index}
defer={!disableOptimizedLoading}
defer={scriptProps.defer ?? !disableOptimizedLoading}
nonce={props.nonce}
data-nscript="beforeInteractive"
crossOrigin={props.crossOrigin || crossOrigin}
Expand Down

0 comments on commit bc0816f

Please sign in to comment.