feat(performance): Core Web Vitals optimizations
- Font optimization: Replace @font-face with next/font/google (DM Sans, Inter) for faster font loading and no render-blocking - Image optimization: Add Unsplash to remotePatterns, configure AVIF/WebP formats, add device/image sizes - Convert native <img> tags to next/image with proper sizing and priority for LCP images - Add optimizePackageImports for lucide-react and framer-motion to reduce bundle size - Fix CLS: Urgency message uses fixed min-height instead of animated height - Fix CLS: ProductCard quick-add button uses opacity instead of translate for hover - Convert HeroVideo scroll indicator to CSS animation - Script loading: Rybbit uses lazyOnload strategy for better INP
This commit is contained in:
@@ -31,6 +31,9 @@ const nextConfig: NextConfig = {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
|
formats: ["image/avif", "image/webp"],
|
||||||
|
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048],
|
||||||
|
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
@@ -52,8 +55,16 @@ const nextConfig: NextConfig = {
|
|||||||
hostname: "**.saleor.cloud",
|
hostname: "**.saleor.cloud",
|
||||||
pathname: "/**",
|
pathname: "/**",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
protocol: "https",
|
||||||
|
hostname: "images.unsplash.com",
|
||||||
|
pathname: "/**",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
experimental: {
|
||||||
|
optimizePackageImports: ["lucide-react", "framer-motion"],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withNextIntl(nextConfig);
|
export default withNextIntl(nextConfig);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { getPageMetadata } from "@/lib/i18n/pageMetadata";
|
|||||||
import { isValidLocale, DEFAULT_LOCALE, type Locale } from "@/lib/i18n/locales";
|
import { isValidLocale, DEFAULT_LOCALE, type Locale } from "@/lib/i18n/locales";
|
||||||
import { getPageKeywords } from "@/lib/seo/keywords";
|
import { getPageKeywords } from "@/lib/seo/keywords";
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
|
import Image from "next/image";
|
||||||
|
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
||||||
|
|
||||||
@@ -67,10 +68,13 @@ export default async function AboutPage({ params }: AboutPageProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="relative h-[400px] md:h-[500px] overflow-hidden">
|
<div className="relative h-[400px] md:h-[500px] overflow-hidden">
|
||||||
<img
|
<Image
|
||||||
src="https://images.unsplash.com/photo-1608571423902-eed4a5ad8108?q=80&w=2000&auto=format&fit=crop"
|
src="https://images.unsplash.com/photo-1608571423902-eed4a5ad8108?q=80&w=2000&auto=format&fit=crop"
|
||||||
alt={metadata.about.productionAlt}
|
alt={metadata.about.productionAlt}
|
||||||
className="w-full h-full object-cover"
|
fill
|
||||||
|
priority
|
||||||
|
className="object-cover"
|
||||||
|
sizes="100vw"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-0 bg-black/20" />
|
<div className="absolute inset-0 bg-black/20" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export default async function LocaleLayout({
|
|||||||
<Script
|
<Script
|
||||||
src="/api/script.js"
|
src="/api/script.js"
|
||||||
data-site-id={RYBBIT_SITE_ID}
|
data-site-id={RYBBIT_SITE_ID}
|
||||||
strategy="afterInteractive"
|
strategy="lazyOnload"
|
||||||
/>
|
/>
|
||||||
<NextIntlClientProvider messages={messages}>
|
<NextIntlClientProvider messages={messages}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { getPageMetadata } from "@/lib/i18n/pageMetadata";
|
|||||||
import { isValidLocale, DEFAULT_LOCALE, getSaleorLocale, type Locale } from "@/lib/i18n/locales";
|
import { isValidLocale, DEFAULT_LOCALE, getSaleorLocale, type Locale } from "@/lib/i18n/locales";
|
||||||
import { getPageKeywords, getBrandKeywords } from "@/lib/seo/keywords";
|
import { getPageKeywords, getBrandKeywords } from "@/lib/seo/keywords";
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
|
import Image from "next/image";
|
||||||
|
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
||||||
|
|
||||||
@@ -157,10 +158,12 @@ export default async function Homepage({ params }: { params: Promise<{ locale: s
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative aspect-[4/3] bg-[#e8f0f5] rounded-lg overflow-hidden">
|
<div className="relative aspect-[4/3] bg-[#e8f0f5] rounded-lg overflow-hidden">
|
||||||
<img
|
<Image
|
||||||
src="https://images.unsplash.com/photo-1608571423902-eed4a5ad8108?q=80&w=800&auto=format&fit=crop"
|
src="https://images.unsplash.com/photo-1608571423902-eed4a5ad8108?q=80&w=800&auto=format&fit=crop"
|
||||||
alt={metadata.home.productionAlt}
|
alt={metadata.home.productionAlt}
|
||||||
className="w-full h-full object-cover"
|
fill
|
||||||
|
className="object-cover"
|
||||||
|
sizes="(max-width: 768px) 100vw, 50vw"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -53,8 +53,7 @@
|
|||||||
--color-cta-hover: #333333;
|
--color-cta-hover: #333333;
|
||||||
--color-overlay: rgba(0, 0, 0, 0.4);
|
--color-overlay: rgba(0, 0, 0, 0.4);
|
||||||
|
|
||||||
--font-display: 'DM Sans', sans-serif;
|
/* Font variables will be set by next/font in layout.tsx */
|
||||||
--font-body: 'Inter', sans-serif;
|
|
||||||
|
|
||||||
--transition-fast: 150ms ease;
|
--transition-fast: 150ms ease;
|
||||||
--transition-base: 250ms ease;
|
--transition-base: 250ms ease;
|
||||||
@@ -66,26 +65,9 @@
|
|||||||
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
|
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================
|
|
||||||
FONT IMPORTS
|
|
||||||
============================================ */
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: 'DM Sans';
|
|
||||||
src: url('https://fonts.gstatic.com/s/dmsans/v15/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAopxhS2f3ZGMZpg.woff2') format('woff2');
|
|
||||||
font-weight: 400 700;
|
|
||||||
font-display: swap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Inter';
|
|
||||||
src: url('https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hjp-Ek-_EeA.woff2') format('woff2');
|
|
||||||
font-weight: 400 700;
|
|
||||||
font-display: swap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ============================================
|
/* ============================================
|
||||||
BASE STYLES (in Tailwind base layer)
|
BASE STYLES (in Tailwind base layer)
|
||||||
|
Fonts loaded via next/font in layout.tsx
|
||||||
============================================ */
|
============================================ */
|
||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
@@ -266,6 +248,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================
|
||||||
|
SCROLL INDICATOR ANIMATION
|
||||||
|
============================================ */
|
||||||
|
|
||||||
|
@keyframes scrollBounce {
|
||||||
|
0%, 100% { transform: translateY(0); }
|
||||||
|
50% { transform: translateY(8px); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.scroll-indicator {
|
||||||
|
animation: scrollBounce 1.5s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
/* ============================================
|
/* ============================================
|
||||||
UTILITIES
|
UTILITIES
|
||||||
============================================ */
|
============================================ */
|
||||||
|
|||||||
@@ -1,9 +1,22 @@
|
|||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
import type { Metadata, Viewport } from "next";
|
import type { Metadata, Viewport } from "next";
|
||||||
|
import { DM_Sans, Inter } from "next/font/google";
|
||||||
import ErrorBoundary from "@/components/providers/ErrorBoundary";
|
import ErrorBoundary from "@/components/providers/ErrorBoundary";
|
||||||
import { SUPPORTED_LOCALES } from "@/lib/i18n/locales";
|
import { SUPPORTED_LOCALES } from "@/lib/i18n/locales";
|
||||||
import { OrganizationSchema } from "@/components/seo";
|
import { OrganizationSchema } from "@/components/seo";
|
||||||
|
|
||||||
|
const dmSans = DM_Sans({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-display",
|
||||||
|
display: "swap",
|
||||||
|
});
|
||||||
|
|
||||||
|
const inter = Inter({
|
||||||
|
subsets: ["latin"],
|
||||||
|
variable: "--font-body",
|
||||||
|
display: "swap",
|
||||||
|
});
|
||||||
|
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://manoonoils.com";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
@@ -39,7 +52,7 @@ export default async function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<html suppressHydrationWarning>
|
<html suppressHydrationWarning className={`${dmSans.variable} ${inter.variable}`}>
|
||||||
<body className="antialiased" suppressHydrationWarning>
|
<body className="antialiased" suppressHydrationWarning>
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import Image from "next/image";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown } from "lucide-react";
|
||||||
|
|
||||||
@@ -22,13 +23,16 @@ export default function HeroVideo({ locale = "sr" }: HeroVideoProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="relative min-h-screen w-full overflow-hidden">
|
<section className="relative min-h-screen w-full overflow-hidden">
|
||||||
{/* Background Image with Overlay */}
|
{/* Background Image with Overlay - Using next/image for LCP optimization */}
|
||||||
<div
|
<div className="absolute inset-0">
|
||||||
className="absolute inset-0 bg-cover bg-center bg-no-repeat"
|
<Image
|
||||||
style={{
|
src="https://images.unsplash.com/photo-1608571423902-eed4a5ad8108?q=80&w=2574&auto=format&fit=crop"
|
||||||
backgroundImage: `url('https://images.unsplash.com/photo-1608571423902-eed4a5ad8108?q=80&w=2574&auto=format&fit=crop')`,
|
alt=""
|
||||||
}}
|
fill
|
||||||
>
|
priority
|
||||||
|
className="object-cover"
|
||||||
|
sizes="100vw"
|
||||||
|
/>
|
||||||
<div className="absolute inset-0 bg-gradient-to-b from-black/50 via-black/40 to-black/70" />
|
<div className="absolute inset-0 bg-gradient-to-b from-black/50 via-black/40 to-black/70" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -132,21 +136,16 @@ export default function HeroVideo({ locale = "sr" }: HeroVideoProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Scroll Indicator */}
|
{/* Scroll Indicator */}
|
||||||
<motion.button
|
<button
|
||||||
initial={{ opacity: 0 }}
|
|
||||||
animate={{ opacity: 1 }}
|
|
||||||
transition={{ delay: 1.5, duration: 0.8 }}
|
|
||||||
onClick={scrollToContent}
|
onClick={scrollToContent}
|
||||||
className="absolute bottom-10 left-1/2 -translate-x-1/2 text-white/60 hover:text-white transition-colors cursor-pointer"
|
className="absolute bottom-10 left-1/2 -translate-x-1/2 text-white/60 hover:text-white transition-colors cursor-pointer opacity-0 animate-fade-in"
|
||||||
|
style={{ animationDelay: '1.5s', animationFillMode: 'forwards' }}
|
||||||
aria-label="Scroll to content"
|
aria-label="Scroll to content"
|
||||||
>
|
>
|
||||||
<motion.div
|
<div className="scroll-indicator">
|
||||||
animate={{ y: [0, 8, 0] }}
|
|
||||||
transition={{ repeat: Infinity, duration: 1.5, ease: "easeInOut" }}
|
|
||||||
>
|
|
||||||
<ChevronDown className="w-6 h-6" strokeWidth={1.5} />
|
<ChevronDown className="w-6 h-6" strokeWidth={1.5} />
|
||||||
</motion.div>
|
</div>
|
||||||
</motion.button>
|
</button>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ export default function ProductCard({ product, index = 0, locale = "sr" }: Produ
|
|||||||
<Link href={`/${locale}/products/${localized.slug}`} className="group block">
|
<Link href={`/${locale}/products/${localized.slug}`} className="group block">
|
||||||
<div className="relative w-full aspect-square bg-[#f8f9fa] overflow-hidden mb-4">
|
<div className="relative w-full aspect-square bg-[#f8f9fa] overflow-hidden mb-4">
|
||||||
{image ? (
|
{image ? (
|
||||||
<img
|
<Image
|
||||||
src={image}
|
src={image}
|
||||||
alt={localized.name}
|
alt={localized.name}
|
||||||
className="w-full h-full object-cover object-center transition-transform duration-700 ease-out group-hover:scale-105"
|
fill
|
||||||
loading="lazy"
|
className="object-cover object-center transition-transform duration-700 ease-out group-hover:scale-105"
|
||||||
|
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 25vw"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="absolute inset-0 flex items-center justify-center text-[#999999]">
|
<div className="absolute inset-0 flex items-center justify-center text-[#999999]">
|
||||||
@@ -52,7 +53,7 @@ export default function ProductCard({ product, index = 0, locale = "sr" }: Produ
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="absolute inset-x-0 bottom-0 p-4 translate-y-full group-hover:translate-y-0 transition-transform duration-300">
|
<div className="absolute inset-x-0 bottom-0 p-4 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
|
||||||
<button
|
<button
|
||||||
className="w-full py-3 bg-black text-white text-xs uppercase tracking-[0.1em] hover:bg-[#333333] transition-colors"
|
className="w-full py-3 bg-black text-white text-xs uppercase tracking-[0.1em] hover:bg-[#333333] transition-colors"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|||||||
@@ -245,10 +245,12 @@ export default function ProductDetail({ product, relatedProducts, bundleProducts
|
|||||||
: "border-transparent hover:border-[#999999]"
|
: "border-transparent hover:border-[#999999]"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<img
|
<Image
|
||||||
src={image.url}
|
src={image.url}
|
||||||
alt={image.alt || localized.name}
|
alt={image.alt || localized.name}
|
||||||
className="w-full h-full object-cover"
|
fill
|
||||||
|
className="object-cover"
|
||||||
|
sizes="100px"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
@@ -256,10 +258,13 @@ export default function ProductDetail({ product, relatedProducts, bundleProducts
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="relative w-full aspect-square bg-[#f8f9fa] overflow-hidden flex-1">
|
<div className="relative w-full aspect-square bg-[#f8f9fa] overflow-hidden flex-1">
|
||||||
<img
|
<Image
|
||||||
src={images[selectedImage].url}
|
src={images[selectedImage].url}
|
||||||
alt={images[selectedImage].alt || localized.name}
|
alt={images[selectedImage].alt || localized.name}
|
||||||
className="w-full h-full object-cover"
|
fill
|
||||||
|
priority
|
||||||
|
className="object-cover"
|
||||||
|
sizes="(max-width: 768px) 100vw, 50vw"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{images.length > 1 && (
|
{images.length > 1 && (
|
||||||
@@ -307,17 +312,15 @@ export default function ProductDetail({ product, relatedProducts, bundleProducts
|
|||||||
transition={{ duration: 0.6, delay: 0.2 }}
|
transition={{ duration: 0.6, delay: 0.2 }}
|
||||||
className="lg:pl-8"
|
className="lg:pl-8"
|
||||||
>
|
>
|
||||||
<motion.div
|
<div className="min-h-[52px] flex items-center">
|
||||||
key={urgencyIndex}
|
<div
|
||||||
initial={{ opacity: 0, y: -10 }}
|
className="bg-white/80 backdrop-blur-sm text-[#1a1a1a] py-3 px-4 rounded-lg mb-4 text-sm font-medium text-left w-full"
|
||||||
animate={{ opacity: 1, y: 0 }}
|
key={urgencyIndex}
|
||||||
exit={{ opacity: 0, y: 10 }}
|
>
|
||||||
transition={{ duration: 0.3 }}
|
<span className="mr-2">{urgencyMessages[urgencyIndex].icon}</span>
|
||||||
className="bg-white/80 backdrop-blur-sm text-[#1a1a1a] py-3 rounded-lg mb-4 text-sm font-medium text-left"
|
{urgencyMessages[urgencyIndex].text}
|
||||||
>
|
</div>
|
||||||
<span className="mr-2">{urgencyMessages[urgencyIndex].icon}</span>
|
</div>
|
||||||
{urgencyMessages[urgencyIndex].text}
|
|
||||||
</motion.div>
|
|
||||||
|
|
||||||
<h1 className="text-3xl md:text-4xl font-medium mb-4 tracking-tight">
|
<h1 className="text-3xl md:text-4xl font-medium mb-4 tracking-tight">
|
||||||
{localized.name}
|
{localized.name}
|
||||||
|
|||||||
Reference in New Issue
Block a user