Skip to content

Commit bf96ca9

Browse files
author
Sebastian Fix
committed
wip
1 parent 4078e3e commit bf96ca9

7 files changed

Lines changed: 163 additions & 28 deletions

File tree

app/Http/Controllers/Sitemap/SitemapController.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,43 @@ public function __invoke(): Response
4444
});
4545

4646
return response(content: $content)
47-
->header('Content-Type', 'application/xml');
47+
->header('Content-Type', 'application/xml')
48+
->header('Cache-Control', 'public, max-age=3600'); // Cache for 1 hour
4849
}
4950

5051
private function builder(): void
5152
{
5253
$this->addDefaultRoutesToSitemap();
5354

55+
// Use chunked queries to prevent memory issues
5456
News::whereNotNull('published_at')
5557
->with('references')
56-
->each(function (News $news): void {
57-
$this->addLocalizedPageSet(
58-
page: (new PageAction(locale: null, routeName: null))->news(news: $news, withReferences: true),
59-
);
58+
->chunk(100, function ($news) {
59+
foreach ($news as $item) {
60+
$this->addLocalizedPageSet(
61+
page: (new PageAction(locale: null, routeName: null))->news(news: $item, withReferences: true),
62+
);
63+
}
6064
});
6165

6266
Service::where('published', true)
6367
->with('references')
64-
->each(function (Service $service): void {
65-
$this->addLocalizedPageSet(
66-
page: (new PageAction(locale: null, routeName: null))->service(service: $service, withReferences: true),
67-
);
68+
->chunk(100, function ($services) {
69+
foreach ($services as $item) {
70+
$this->addLocalizedPageSet(
71+
page: (new PageAction(locale: null, routeName: null))->service(service: $item, withReferences: true),
72+
);
73+
}
6874
});
6975

7076
Product::where('published', true)
7177
->with('references')
72-
->each(function (Product $product): void {
73-
$this->addLocalizedPageSet(
74-
page: (new PageAction(locale: null, routeName: null))->product(product: $product, withReferences: true),
75-
);
78+
->chunk(100, function ($products) {
79+
foreach ($products as $item) {
80+
$this->addLocalizedPageSet(
81+
page: (new PageAction(locale: null, routeName: null))->product(product: $item, withReferences: true),
82+
);
83+
}
7684
});
7785
}
7886

package-lock.json

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

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
"laravel-vite-plugin": "^1.2.0",
1818
"tailwindcss": "^4.1.2",
1919
"vite": "^6.3.4"
20+
},
21+
"devDependencies": {
22+
"terser": "^5.43.1"
2023
}
2124
}

resources/css/app.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,39 @@
1111
display: none !important;
1212
}
1313

14+
/* Optimize font loading */
1415
@font-face {
1516
font-family: 'Poppins';
1617
font-style: normal;
1718
font-weight: 400;
1819
font-display: swap;
20+
font-preload: true;
1921
src: url('../fonts/poppins/poppins-regular.woff2') format('woff2');
2022
}
2123

24+
/* Critical CSS for above-the-fold content */
2225
body {
2326
font-family: 'Poppins', ui-sans-serif, system-ui, sans-serif;
2427
@apply text-gray-800;
28+
/* Optimize text rendering */
29+
text-rendering: optimizeSpeed;
30+
-webkit-font-smoothing: antialiased;
31+
-moz-osx-font-smoothing: grayscale;
32+
}
33+
34+
/* Optimize images */
35+
img {
36+
max-width: 100%;
37+
height: auto;
38+
}
39+
40+
/* Optimize animations */
41+
@media (prefers-reduced-motion: reduce) {
42+
*,
43+
*::before,
44+
*::after {
45+
animation-duration: 0.01ms !important;
46+
animation-iteration-count: 1 !important;
47+
transition-duration: 0.01ms !important;
48+
}
2549
}

resources/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Alpine.data('navigation', () => ({
1515
},
1616
}))
1717

18-
Alpine.start()
18+
Alpine.start()

resources/views/layouts/app.blade.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
class="scroll-smooth"
55
>
66
<head>
7-
87
<meta charset="utf-8"/>
8+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
9+
<meta name="csrf-token" content="{{ csrf_token() }}"/>
10+
11+
<!-- Resource hints for performance -->
12+
<link rel="preconnect" href="https://res.cloudinary.com">
13+
<link rel="dns-prefetch" href="https://res.cloudinary.com">
14+
<link rel="preconnect" href="https://cdn.usefathom.com">
15+
<link rel="dns-prefetch" href="https://cdn.usefathom.com">
916

10-
<meta
11-
name="viewport"
12-
content="width=device-width, initial-scale=1"
13-
/>
14-
<meta
15-
name="csrf-token"
16-
content="{{ csrf_token() }}"
17-
/>
17+
<!-- Preload critical resources -->
18+
<link rel="preload" href="{{ asset('fonts/poppins/poppins-regular.woff2') }}" as="font" type="font/woff2" crossorigin>
1819

1920
@include('layouts._partials._seo')
2021
@include('layouts._partials._favicons')
2122

2223
@vite(['resources/js/app.js'])
2324

24-
2525
</head>
2626
<body class="font-sans antialiased">
2727

vite.config.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,35 @@ import laravel from 'laravel-vite-plugin';
55
import tailwindcss from "@tailwindcss/vite";
66

77
export default defineConfig({
8-
plugins: [laravel({
9-
input: ['resources/js/app.js'], refresh: [`resources/views/**/*`],
10-
}), tailwindcss(),], server: {
8+
plugins: [
9+
laravel({
10+
input: ['resources/js/app.js'],
11+
refresh: [`resources/views/**/*`],
12+
}),
13+
tailwindcss(),
14+
],
15+
server: {
1116
cors: true,
1217
},
13-
});
18+
build: {
19+
// Optimize build performance
20+
target: 'esnext',
21+
// Use default minification instead of terser
22+
minify: 'esbuild',
23+
rollupOptions: {
24+
output: {
25+
manualChunks: {
26+
alpine: ['@alpinejs/csp'],
27+
},
28+
},
29+
},
30+
// Enable source maps for debugging
31+
sourcemap: false,
32+
// Optimize chunk size
33+
chunkSizeWarningLimit: 1000,
34+
},
35+
// Optimize development server
36+
optimizeDeps: {
37+
include: ['@alpinejs/csp'],
38+
},
39+
});

0 commit comments

Comments
 (0)