From 240d44842ab49b51c073d68f7b7147f30297ae3e Mon Sep 17 00:00:00 2001 From: gbanyan Date: Sat, 14 Feb 2026 00:09:59 +0800 Subject: [PATCH] chore: add browser optimizations - Add browserslist (Chrome 111+, Edge 111+, Firefox 111+, Safari 16.4+) - Add loading=lazy and decoding=async to markdown images for better LCP Co-authored-by: Cursor --- contentlayer.config.ts | 5 ++++- package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/contentlayer.config.ts b/contentlayer.config.ts index c311be5..6fc7b39 100644 --- a/contentlayer.config.ts +++ b/contentlayer.config.ts @@ -103,7 +103,7 @@ export default makeSource({ [rehypeAutolinkHeadings, { behavior: 'wrap' }], /** * Rewrite markdown image src from relative "../assets/..." to - * absolute "/assets/..." so they are served from Next.js public/. + * absolute "/assets/..." and add lazy loading for cross-browser performance. */ () => (tree: any) => { visit(tree, 'element', (node: any) => { @@ -118,6 +118,9 @@ export default makeSource({ } else if (src.startsWith('assets/')) { node.properties.src = '/' + src.replace(/^\/?/, ''); } + // Lazy load images for better LCP and bandwidth (Chrome, Firefox, Safari, Edge) + node.properties.loading = 'lazy'; + node.properties.decoding = 'async'; } }); } diff --git a/package.json b/package.json index b6f883f..84089b6 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "author": "", "license": "ISC", "type": "module", + "browserslist": ["chrome 111", "edge 111", "firefox 111", "safari 16.4"], "dependencies": { "@emotion/is-prop-valid": "^1.4.0", "@radix-ui/react-dialog": "^1.1.15",