File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
packages/qwik/src/optimizer/src/plugins Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
69
69
const fileFilter : QwikVitePluginOptions [ 'fileFilter' ] = qwikViteOpts . fileFilter
70
70
? ( id , type ) => TRANSFORM_REGEX . test ( id ) || qwikViteOpts . fileFilter ! ( id , type )
71
71
: ( ) => true ;
72
+ const disableFontPreload = qwikViteOpts . disableFontPreload ?? false ;
72
73
const injections : GlobalInjections [ ] = [ ] ;
73
74
const qwikPlugin = createQwikPlugin ( qwikViteOpts . optimizerOptions ) ;
74
75
@@ -523,7 +524,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
523
524
}
524
525
} else {
525
526
const selectedFont = FONTS . find ( ( ext ) => fileName . endsWith ( ext ) ) ;
526
- if ( selectedFont ) {
527
+ if ( selectedFont && ! disableFontPreload ) {
527
528
injections . unshift ( {
528
529
tag : 'link' ,
529
530
location : 'head' ,
@@ -930,6 +931,15 @@ interface QwikVitePluginCommonOptions {
930
931
* to be stable between releases
931
932
*/
932
933
experimental ?: ( keyof typeof ExperimentalFeatures ) [ ] ;
934
+
935
+ /**
936
+ * Disables automatic preloading of font assets (WOFF/WOFF2/TTF) found in the build output. When
937
+ * enabled, the plugin will not add `<link rel="preload">` tags for font files in the document
938
+ * head.
939
+ *
940
+ * Disabling may impact Cumulative Layout Shift (CLS) metrics.
941
+ */
942
+ disableFontPreload ?: boolean ;
933
943
}
934
944
935
945
interface QwikVitePluginCSROptions extends QwikVitePluginCommonOptions {
You can’t perform that action at this time.
0 commit comments