Skip to content

Commit b33f0e7

Browse files
authored
Merge pull request #281 from sourcectl/perf/lazy-load-images
perf: add loading="lazy" to below-fold images
2 parents ace3b04 + 692d71b commit b33f0e7

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/components/NewsPostPreview.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const imageOrder = isEven ? 'order-0 lg:order-1' : 'order-0';
4040
</div>
4141
<div class={`w-full lg:w-1/2 px-4 mb-8 ${imageOrder}`}>
4242
<a href={entry.url} title={frontmatter.title}>
43-
<img class="w-full h-80 object-cover rounded" src={frontmatter.coverImage} alt={frontmatter.title} title={frontmatter.title} />
43+
<img class="w-full h-80 object-cover rounded" src={frontmatter.coverImage} alt={frontmatter.title} title={frontmatter.title} loading="lazy" />
4444
</a>
4545
</div>
4646
</div>

src/layouts/NewsSingleViewLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const description = cutText(content.description, 200);
3737
</div>
3838
</div>
3939
<div class="mb-8">
40-
<img class="h-80 mx-auto mb-6 object-cover rounded" src={content.coverImage} alt={content.title} title={content.title} />
40+
<img class="h-80 mx-auto mb-6 object-cover rounded" src={content.coverImage} alt={content.title} title={content.title} loading="lazy" />
4141
</div>
4242
<div id="changelog_content" class="max-w-2xl mx-auto">
4343
<slot />

src/pages/index.astro

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import Layout from '../layouts/StandardLayout.astro';
3131
<div class="flex flex-wrap">
3232
<div class="relative w-full lg:w-1/2 px-4 lg:h-128">
3333
<div class="relative lg:absolute left-0 top-0 lg:max-w-6xl mx-auto lg:-ml-64">
34-
<img class="lg:h-128" src="/images/elements/macbook.png" alt="" />
34+
<img class="lg:h-128" src="/images/elements/macbook.png" alt="" loading="lazy" />
3535
<div class="absolute" style="top: 5.8%; left: 14.6%; width: 72.8%; height: 76.8%;">
36-
<img class="object-cover w-full h-full" src="/images/screenshots/sourcectl-repo-view.png" alt="sourcectl Repository view" title="sourcectl Repository view" />
36+
<img class="object-cover w-full h-full" src="/images/screenshots/sourcectl-repo-view.png" alt="sourcectl Repository view" title="sourcectl Repository view" loading="lazy" />
3737
</div>
3838
</div>
3939
</div>
@@ -76,9 +76,9 @@ import Layout from '../layouts/StandardLayout.astro';
7676
</div>
7777
<div class="relative order-0 lg:order-1 w-full lg:w-1/2 px-4 lg:h-128">
7878
<div class="relative lg:absolute right-0 top-0 lg:max-w-6xl mx-auto lg:-mr-64">
79-
<img class="lg:h-128" src="/images/elements/macbook.png" alt="" />
79+
<img class="lg:h-128" src="/images/elements/macbook.png" alt="" loading="lazy" />
8080
<div class="absolute" style="top: 5.8%; left: 14.6%; width: 72.8%; height: 76.8%;">
81-
<img class="object-cover w-full h-full" src="/images/screenshots/sourcectl-dashboard.png" alt="sourcectl Dashboard" title="sourcectl Dashboard" />
81+
<img class="object-cover w-full h-full" src="/images/screenshots/sourcectl-dashboard.png" alt="sourcectl Dashboard" title="sourcectl Dashboard" loading="lazy" />
8282
</div>
8383
</div>
8484
</div>
@@ -188,7 +188,7 @@ import Layout from '../layouts/StandardLayout.astro';
188188
</div>
189189
</div>
190190
<div class="w-full md:w-1/2 px-3 order-0 md:order-1 mb-12 md:mb-0">
191-
<img class="sm:max-w-sm lg:max-w-full mx-auto" src="/images/illustrations/work-tv.png" alt="" />
191+
<img class="sm:max-w-sm lg:max-w-full mx-auto" src="/images/illustrations/work-tv.png" alt="" loading="lazy" />
192192
</div>
193193
</div>
194194
</div>
@@ -206,7 +206,7 @@ import Layout from '../layouts/StandardLayout.astro';
206206
<div class="flex flex-wrap -mx-3">
207207
<div class="w-full md:w-1/2 lg:w-1/3 px-3 mb-6">
208208
<div class="pt-16 pb-8 px-4 text-center bg-white rounded shadow">
209-
<img class="h-20 mb-6 mx-auto" src="/images/illustrations/people.png" alt="" />
209+
<img class="h-20 mb-6 mx-auto" src="/images/illustrations/people.png" alt="" loading="lazy" />
210210
<h3 class="mb-2 text-4xl font-bold font-heading">In the Open</h3>
211211
<span class="text-4xl text-sourcectl-orange font-bold font-heading">Free</span>
212212
<p class="mt-2 mb-8 text-blueGray-500">&nbsp;</p>
@@ -240,7 +240,7 @@ import Layout from '../layouts/StandardLayout.astro';
240240
</div>
241241
<div class="w-full md:w-1/2 lg:w-1/3 px-3 mb-6">
242242
<div class="pt-16 pb-8 px-4 text-center text-white bg-gray-700 rounded shadow">
243-
<img class="h-20 mb-6 mx-auto" src="/images/illustrations/job-interview.png" alt="" />
243+
<img class="h-20 mb-6 mx-auto" src="/images/illustrations/job-interview.png" alt="" loading="lazy" />
244244
<h3 class="mb-2 text-4xl font-bold font-heading">Professional</h3>
245245
<span class="text-4xl font-bold font-heading">$199.99</span>
246246
<p class="mt-2 mb-8">per month</p>
@@ -289,7 +289,7 @@ import Layout from '../layouts/StandardLayout.astro';
289289
</div>
290290
<div class="w-full lg:w-1/3 px-3 mb-6">
291291
<div class="pt-16 pb-8 px-4 text-center bg-white rounded shadow">
292-
<img class="h-20 mb-6 mx-auto" src="/images/illustrations/team-management.png" alt="" />
292+
<img class="h-20 mb-6 mx-auto" src="/images/illustrations/team-management.png" alt="" loading="lazy" />
293293
<h3 class="mb-2 text-4xl font-bold font-heading">Enterprise</h3>
294294
<span class="text-4xl text-sourcectl-orange font-bold font-heading">$499.99</span>
295295
<p class="mt-2 mb-8 text-blueGray-500">per month</p>

0 commit comments

Comments
 (0)