Skip to content

Commit b70c51e

Browse files
authored
docs(linter): google_font_preconnect: linter rules (oxc-project#11189)
1 parent 699ec64 commit b70c51e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/oxc_linter/src/rules/nextjs/google_font_preconnect.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ pub struct GoogleFontPreconnect;
2222
declare_oxc_lint!(
2323
/// ### What it does
2424
///
25+
/// Enforces the presence of `rel="preconnect"` when using Google Fonts via `<link>` tags.
2526
///
2627
/// ### Why is this bad?
2728
///
29+
/// When using Google Fonts, it's recommended to include a preconnect resource hint to establish early connections to the required origin.
30+
/// Without preconnect, the browser needs to perform DNS lookups, TCP handshakes, and TLS negotiations before it can download the font files,
31+
/// which can delay font loading and impact performance.
2832
///
2933
/// ### Examples
3034
///
3135
/// Examples of **incorrect** code for this rule:
3236
/// ```javascript
37+
/// <link href="https://fonts.gstatic.com" />
38+
/// <link rel="preload" href="https://fonts.gstatic.com" />
3339
/// ```
3440
///
3541
/// Examples of **correct** code for this rule:
3642
/// ```javascript
43+
/// <link rel="preconnect" href="https://fonts.gstatic.com" />
3744
/// ```
3845
GoogleFontPreconnect,
3946
nextjs,

0 commit comments

Comments
 (0)