Skip to content

Commit f22e220

Browse files
committed
Address feedback from PageSpeed.
1 parent f39c4c0 commit f22e220

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

.cursorrules

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ excerpt: "ملخص قصير"
100100
9. Test mobile responsiveness
101101
10. Verify language toggle works
102102

103+
### Performance (PageSpeed)
104+
11. Use WebP images with JPG/PNG fallbacks
105+
12. Add `loading="lazy"` to images below the fold
106+
13. Add `loading="eager"` and `fetchpriority="high"` to hero/LCP images
107+
14. Preload critical fonts with `<link rel="preload" as="font" crossorigin>`
108+
15. Add `font-display: swap` to all `@font-face` declarations
109+
16. Preload hero/LCP images on pages where they appear
110+
17. Use async CSS loading: `<link rel="preload" as="style" onload="this.rel='stylesheet'">`
111+
18. Inline critical above-the-fold CSS in `<head>`
112+
19. Specify `width` and `height` on images to prevent layout shift
113+
20. Run `make prod-build` before committing
114+
103115
---
104116

105117
## 🚫 NEVER
@@ -115,6 +127,17 @@ excerpt: "ملخص قصير"
115127
9. Merge without testing both languages
116128
10. Create cramped layouts — white space is design
117129

130+
### Performance (PageSpeed)
131+
11. Serve unoptimized images (always use WebP, compress JPG/PNG)
132+
12. Use images larger than needed (resize to display size)
133+
13. Forget `loading="lazy"` on below-fold images
134+
14. Chain critical requests (HTML → CSS → Font) — preload instead
135+
15. Use render-blocking CSS without inlining critical styles
136+
16. Load fonts without `font-display: swap`
137+
17. Omit `width`/`height` on images (causes layout shift)
138+
18. Use external font CDNs — self-host fonts instead
139+
19. Ship unminified CSS (use `sass: style: compressed` in `_config.yml`)
140+
118141
---
119142

120143
## ✅ VERIFICATION (After Every Change)

_layouts/default.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,33 @@
2828
<!-- Theme Color -->
2929
<meta name="theme-color" content="#B34E36">
3030

31-
<!-- Fonts (self-hosted) -->
31+
<!-- Preload critical fonts (breaks render-blocking chain) -->
3232
{%- if lang == 'ar' -%}
3333
<link rel="preload" href="{{ '/assets/fonts/Tajawal-Regular.woff2' | relative_url }}" as="font" type="font/woff2" crossorigin>
3434
<link rel="preload" href="{{ '/assets/fonts/Tajawal-Bold.woff2' | relative_url }}" as="font" type="font/woff2" crossorigin>
35+
<link rel="preload" href="{{ '/assets/fonts/Tajawal-ExtraBold.woff2' | relative_url }}" as="font" type="font/woff2" crossorigin>
3536
{%- else -%}
3637
<link rel="preload" href="{{ '/assets/fonts/DMSans-Regular.woff2' | relative_url }}" as="font" type="font/woff2" crossorigin>
3738
<link rel="preload" href="{{ '/assets/fonts/DMSans-Bold.woff2' | relative_url }}" as="font" type="font/woff2" crossorigin>
3839
{%- endif -%}
3940

40-
<!-- Styles -->
41-
<link rel="stylesheet" href="{{ '/assets/css/styles.css' | relative_url }}">
41+
<!-- Preload hero image (LCP element) -->
42+
{%- if page.layout == 'home' or page.url == '/ar/' or page.url == '/en/' -%}
43+
<link rel="preload" href="{{ '/assets/img/logo-512-hq.webp' | relative_url }}" as="image" type="image/webp" fetchpriority="high">
44+
{%- endif -%}
45+
46+
<!-- Critical inline CSS (prevents FOUC) -->
47+
<style>
48+
:root{--sand:#F4E6C4;--terracotta:#B34E36;--night:#152029;--ink:#21313B}
49+
html,body{margin:0;padding:0;color:var(--ink);background:linear-gradient(180deg,#FFFDF6 0%,var(--sand) 100%);min-height:100vh}
50+
html[dir="rtl"],html[dir="rtl"] body{font-family:'Tajawal',sans-serif;line-height:1.8}
51+
html[dir="ltr"],html[dir="ltr"] body{font-family:'DM Sans',sans-serif;line-height:1.6}
52+
.wrap{max-width:940px;margin:0 auto;padding:32px 20px 64px}
53+
</style>
54+
55+
<!-- Full styles (async load to avoid render blocking) -->
56+
<link rel="preload" href="{{ '/assets/css/styles.css' | relative_url }}" as="style" onload="this.onload=null;this.rel='stylesheet'">
57+
<noscript><link rel="stylesheet" href="{{ '/assets/css/styles.css' | relative_url }}"></noscript>
4258

4359
<!-- SEO -->
4460
{% seo %}

0 commit comments

Comments
 (0)