Skip to content

Commit 63b8d94

Browse files
committed
🚀 Optimize website performance: compress images, add lazy loading, minify CSS/JS, add cache headers
1 parent af70ad6 commit 63b8d94

21 files changed

Lines changed: 24 additions & 28 deletions

.eleventy.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
// .eleventy.js
21
const pluginRss = require("@11ty/eleventy-plugin-rss");
32
const pluginNavigation = require("@11ty/eleventy-navigation");
4-
53
module.exports = function(eleventyConfig) {
6-
// Plugins
74
eleventyConfig.addPlugin(pluginRss);
85
eleventyConfig.addPlugin(pluginNavigation);
9-
10-
// Static passthrough
116
eleventyConfig.addPassthroughCopy({ "img": "img" });
127
eleventyConfig.addPassthroughCopy({ "css": "css" });
138
eleventyConfig.addPassthroughCopy({ "files": "files" });
14-
15-
// Date filters (fallbacks)
169
eleventyConfig.addFilter("htmlDateString", (d) => new Date(d).toISOString().slice(0, 10));
1710
eleventyConfig.addFilter("readableDate", (d) =>
1811
new Date(d).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" })
1912
);
20-
21-
// Tags utilities زي Eleventy Base Blog
2213
const EXCLUDED = new Set(["all","nav","post","posts"]);
2314
eleventyConfig.addFilter("filterTagList", (tags) => (tags || []).filter((t) => !EXCLUDED.has(t)));
2415
eleventyConfig.addCollection("tagList", (api) => {
@@ -28,7 +19,6 @@ module.exports = function(eleventyConfig) {
2819
});
2920
return Array.from(set).sort();
3021
});
31-
3222
return {
3323
dir: { input: ".", includes: "_includes", data: "_data", output: "_site" },
3424
htmlTemplateEngine: "njk",

.htaccess

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<IfModule mod_expires.c>
2+
ExpiresActive on
3+
ExpiresByType text/css "access plus 1 year"
4+
ExpiresByType application/javascript "access plus 1 year"
5+
ExpiresByType image/png "access plus 1 year"
6+
ExpiresByType image/jpg "access plus 1 year"
7+
ExpiresByType image/jpeg "access plus 1 year"
8+
</IfModule>
9+
10+
<IfModule mod_deflate.c>
11+
AddOutputFilterByType DEFLATE text/plain
12+
AddOutputFilterByType DEFLATE text/html
13+
AddOutputFilterByType DEFLATE text/xml
14+
AddOutputFilterByType DEFLATE text/css
15+
AddOutputFilterByType DEFLATE application/xml
16+
AddOutputFilterByType DEFLATE application/xhtml+xml
17+
AddOutputFilterByType DEFLATE application/rss+xml
18+
AddOutputFilterByType DEFLATE application/javascript
19+
AddOutputFilterByType DEFLATE application/x-javascript
20+
</IfModule>

_11ty/getTagList.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,20 @@ module.exports = function(collection) {
33
collection.getAll().forEach(function(item) {
44
if( "tags" in item.data ) {
55
let tags = item.data.tags;
6-
76
tags = tags.filter(function(item) {
87
switch(item) {
9-
// this list should match the `filter` list in tags.njk
108
case "all":
119
case "nav":
1210
case "post":
1311
case "posts":
1412
return false;
1513
}
16-
1714
return true;
1815
});
19-
2016
for (const tag of tags) {
2117
tagSet.add(tag);
2218
}
2319
}
2420
});
25-
26-
// returning an array in addCollection works in Eleventy 0.5.3
2721
return [...tagSet];
2822
};

_data/concept.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
const fs = require("fs");
22
const path = require("path");
3-
43
function extractNumber(basename) {
54
const m = basename.match(/\d+/);
65
return m ? parseInt(m[0], 10) : -Infinity;
76
}
8-
97
module.exports = function () {
108
const dir = "img/projects/concept-art";
119
if (!fs.existsSync(dir)) return [];
12-
1310
const exts = new Set([".jpg", ".jpeg", ".png", ".webp", ".gif", ".svg"]);
1411
const files = fs
1512
.readdirSync(dir)
@@ -30,7 +27,5 @@ module.exports = function () {
3027
if (b.num !== a.num) return b.num - a.num;
3128
return a.name.localeCompare(b.name);
3229
});
33-
3430
return files;
3531
};
36-

_data/graphic.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
const fs = require("fs");
22
const path = require("path");
3-
4-
// هترتّب حسب الرقم في اسم الملف (تنازلي)، وبعدين حسب الاسم كـ fallback
53
function extractNumber(basename) {
6-
// بيلقط أول رقم في الاسم: 001, 12, 2024 ... الخ
74
const m = basename.match(/\d+/);
85
return m ? parseInt(m[0], 10) : -Infinity; // اللي ملوش رقم يروح في الآخر
96
}
10-
117
module.exports = function () {
128
const dir = "img/projects/graphic-design";
139
if (!fs.existsSync(dir)) return [];
14-
1510
const exts = new Set([".jpg", ".jpeg", ".png", ".webp", ".gif", ".svg"]);
1611
const files = fs
1712
.readdirSync(dir)
@@ -32,7 +27,5 @@ module.exports = function () {
3227
if (b.num !== a.num) return b.num - a.num; // الأكبر رقمًا الأول
3328
return a.name.localeCompare(b.name); // تعادل: رتب ألفبائي
3429
});
35-
3630
return files;
3731
};
38-

css/index.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/prism-base16-monokai.dark.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/style.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/w3.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

img/projects/concept-art/19.png

-764 KB
Loading

0 commit comments

Comments
 (0)