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 <cursoragent@cursor.com>
This commit is contained in:
@@ -103,7 +103,7 @@ export default makeSource({
|
|||||||
[rehypeAutolinkHeadings, { behavior: 'wrap' }],
|
[rehypeAutolinkHeadings, { behavior: 'wrap' }],
|
||||||
/**
|
/**
|
||||||
* Rewrite markdown image src from relative "../assets/..." to
|
* 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) => {
|
() => (tree: any) => {
|
||||||
visit(tree, 'element', (node: any) => {
|
visit(tree, 'element', (node: any) => {
|
||||||
@@ -118,6 +118,9 @@ export default makeSource({
|
|||||||
} else if (src.startsWith('assets/')) {
|
} else if (src.startsWith('assets/')) {
|
||||||
node.properties.src = '/' + src.replace(/^\/?/, '');
|
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';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"browserslist": ["chrome 111", "edge 111", "firefox 111", "safari 16.4"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/is-prop-valid": "^1.4.0",
|
"@emotion/is-prop-valid": "^1.4.0",
|
||||||
"@radix-ui/react-dialog": "^1.1.15",
|
"@radix-ui/react-dialog": "^1.1.15",
|
||||||
|
|||||||
Reference in New Issue
Block a user