[{"data":1,"prerenderedAt":1396},["ShallowReactive",2],{"blog-nuxt-performance-optimization":3},{"id":4,"title":5,"articleType":6,"author":7,"authorSlug":8,"body":9,"cta":1367,"date":1368,"description":1369,"extension":1370,"faq":1371,"featured":1384,"image":1385,"meta":1386,"navigation":1387,"noCtaBox":1384,"path":1388,"readTime":1389,"seo":1390,"seoTitle":1367,"stem":1391,"tags":1392,"__hash__":1395},"blog\u002Fblog\u002Fnuxt-performance-optimization.md","Nuxt Performance Optimization: Best Practices and Tips","TechArticle","Pavel Mironov","pavel-mironov",{"type":10,"value":11,"toc":1341},"minimark",[12,16,21,24,130,133,137,149,152,155,164,168,183,188,199,327,342,346,357,464,475,486,490,493,568,571,684,691,695,698,702,705,724,727,731,738,799,805,823,827,830,837,841,849,986,1001,1007,1010,1089,1096,1213,1220,1224,1231,1242,1246,1249,1261,1265,1269,1276,1280,1283,1287,1294,1298,1301,1305,1313,1317,1325,1329,1337],[13,14,15],"p",{},"Nuxt performance optimization is mostly about three things: images, JavaScript and how pages are rendered and cached. Nuxt has tools for all three, but most of them are opt-in. This guide puts the fixes in priority order, shows the code for each, and explains how to measure whether they worked. The examples target Nuxt 4.",[17,18,20],"h2",{"id":19},"nuxt-performance-optimization-what-to-fix-first","Nuxt Performance Optimization: What to Fix First",[13,22,23],{},"Start your Nuxt performance optimization with the largest image above the fold, then cut the JavaScript the page ships, then cache what doesn't change per request. Those three hit LCP, INP and server response time hardest, and the first one is usually a one-line change.",[25,26,27,43],"table",{},[28,29,30],"thead",{},[31,32,33,37,40],"tr",{},[34,35,36],"th",{},"Fix",[34,38,39],{},"Metric it helps",[34,41,42],{},"Effort",[44,45,46,58,68,78,89,99,110,120],"tbody",{},[31,47,48,52,55],{},[49,50,51],"td",{},"Size and preload the LCP image",[49,53,54],{},"LCP",[49,56,57],{},"Low",[31,59,60,63,66],{},[49,61,62],{},"Lazy load images below the fold",[49,64,65],{},"LCP, data usage",[49,67,57],{},[31,69,70,73,76],{},[49,71,72],{},"Set width and height on images and embeds",[49,74,75],{},"CLS",[49,77,57],{},[31,79,80,83,86],{},[49,81,82],{},"Prerender or cache pages that don't change per request",[49,84,85],{},"TTFB, LCP",[49,87,88],{},"Low to medium",[31,90,91,94,97],{},[49,92,93],{},"Trim data payloads",[49,95,96],{},"TTFB, hydration time",[49,98,57],{},[31,100,101,104,107],{},[49,102,103],{},"Lazy load and lazy hydrate heavy components",[49,105,106],{},"INP, JS size",[49,108,109],{},"Medium",[31,111,112,115,118],{},[49,113,114],{},"Delay third-party scripts",[49,116,117],{},"INP, LCP",[49,119,109],{},[31,121,122,125,128],{},[49,123,124],{},"Self-host fonts with fallback metrics",[49,126,127],{},"CLS, LCP",[49,129,57],{},[13,131,132],{},"Do them in that order unless your measurements point somewhere else.",[17,134,136],{"id":135},"how-to-measure-nuxt-performance","How to Measure Nuxt Performance",[13,138,139,140,144,145,148],{},"Measure a production build, never the dev server. Run ",[141,142,143],"code",{},"npx nuxt build"," and ",[141,146,147],{},"npx nuxt preview",", or test the deployed site.",[13,150,151],{},"For the real picture, open PageSpeed Insights. Its top section shows field data from Chrome users, and that's what Google ranks on. The targets are LCP under 2.5 seconds, INP under 200 milliseconds and CLS under 0.1, measured at the 75th percentile. The Lighthouse report below it is a lab test: useful for finding causes, not for proving a fix worked.",[13,153,154],{},"Inside Nuxt, DevTools has a Payload tab that shows how much data each page sends to the client, an opt-in Timeline for component and composable timings, and Build Analyze for comparing bundle reports between builds.",[13,156,157,158,163],{},"Most of what slows a Nuxt app down at runtime is Vue code, and the same tools apply. Our guide to ",[159,160,162],"a",{"href":161},"\u002Fblog\u002Fvue-js-performance","Vue.js performance optimization"," covers profiling, reactivity and rendering in depth.",[17,165,167],{"id":166},"nuxt-image-optimization","Nuxt Image Optimization",[13,169,170,171,144,174,177,178,182],{},"Images are the largest thing on most pages, so Nuxt image optimization usually moves LCP more than anything else. It also fixes a common layout shift: an image without dimensions pushes the content below it down when it loads. Set ",[141,172,173],{},"width",[141,175,176],{},"height"," on every image, and see ",[159,179,181],{"href":180},"\u002Fblog\u002Fhow-to-fix-cls","how to fix CLS"," for the other causes.",[184,185,187],"h3",{"id":186},"set-up-the-nuxt-image-optimizer","Set Up the Nuxt Image Optimizer",[13,189,190,191,194,195,198],{},"The Nuxt image optimizer is the ",[141,192,193],{},"@nuxt\u002Fimage"," module. Install it with ",[141,196,197],{},"npm i @nuxt\u002Fimage"," and add it to your config:",[200,201,206],"pre",{"className":202,"code":203,"language":204,"meta":205,"style":205},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F nuxt.config.ts\nexport default defineNuxtConfig({\n  modules: ['@nuxt\u002Fimage'],\n  image: {\n    quality: 80,\n    format: ['webp'],\n  },\n})\n","ts","",[141,207,208,217,239,266,277,291,312,318],{"__ignoreMap":205},[209,210,213],"span",{"class":211,"line":212},"line",1,[209,214,216],{"class":215},"sHwdD","\u002F\u002F nuxt.config.ts\n",[209,218,220,224,227,231,235],{"class":211,"line":219},2,[209,221,223],{"class":222},"s7zQu","export",[209,225,226],{"class":222}," default",[209,228,230],{"class":229},"s2Zo4"," defineNuxtConfig",[209,232,234],{"class":233},"sTEyZ","(",[209,236,238],{"class":237},"sMK4o","{\n",[209,240,242,246,249,252,255,258,260,263],{"class":211,"line":241},3,[209,243,245],{"class":244},"swJcz","  modules",[209,247,248],{"class":237},":",[209,250,251],{"class":233}," [",[209,253,254],{"class":237},"'",[209,256,193],{"class":257},"sfazB",[209,259,254],{"class":237},[209,261,262],{"class":233},"]",[209,264,265],{"class":237},",\n",[209,267,269,272,274],{"class":211,"line":268},4,[209,270,271],{"class":244},"  image",[209,273,248],{"class":237},[209,275,276],{"class":237}," {\n",[209,278,280,283,285,289],{"class":211,"line":279},5,[209,281,282],{"class":244},"    quality",[209,284,248],{"class":237},[209,286,288],{"class":287},"sbssI"," 80",[209,290,265],{"class":237},[209,292,294,297,299,301,303,306,308,310],{"class":211,"line":293},6,[209,295,296],{"class":244},"    format",[209,298,248],{"class":237},[209,300,251],{"class":233},[209,302,254],{"class":237},[209,304,305],{"class":257},"webp",[209,307,254],{"class":237},[209,309,262],{"class":233},[209,311,265],{"class":237},[209,313,315],{"class":211,"line":314},7,[209,316,317],{"class":237},"  },\n",[209,319,321,324],{"class":211,"line":320},8,[209,322,323],{"class":237},"}",[209,325,326],{"class":233},")\n",[13,328,329,330,333,334,337,338,341],{},"Then use ",[141,331,332],{},"\u003CNuxtImg>"," instead of ",[141,335,336],{},"\u003Cimg>",". By default it resizes and converts images with IPX on your own server. On a static build, ",[141,339,340],{},"nuxt generate"," optimizes the images at build time and saves the results with the site. That's how this site runs: Nuxt Image with the default provider and prerendered pages. If you already use an image CDN, switch the provider and keep the same markup.",[184,343,345],{"id":344},"use-modern-formats-and-responsive-sizes","Use Modern Formats and Responsive Sizes",[13,347,348,349,352,353,356],{},"Two props do most of the work. ",[141,350,351],{},"format"," picks the output format, and ",[141,354,355],{},"sizes"," makes the module generate several widths so phones don't download desktop images:",[200,358,362],{"className":359,"code":360,"language":361,"meta":205,"style":205},"language-vue shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003CNuxtImg\n  src=\"\u002Fimages\u002Fteam.jpg\"\n  width=\"800\"\n  height=\"533\"\n  sizes=\"100vw sm:50vw md:400px\"\n  format=\"webp\"\n  alt=\"The team at work\"\n\u002F>\n","vue",[141,363,364,372,390,404,418,432,445,459],{"__ignoreMap":205},[209,365,366,369],{"class":211,"line":212},[209,367,368],{"class":237},"\u003C",[209,370,371],{"class":244},"NuxtImg\n",[209,373,374,378,381,384,387],{"class":211,"line":219},[209,375,377],{"class":376},"spNyl","  src",[209,379,380],{"class":237},"=",[209,382,383],{"class":237},"\"",[209,385,386],{"class":257},"\u002Fimages\u002Fteam.jpg",[209,388,389],{"class":237},"\"\n",[209,391,392,395,397,399,402],{"class":211,"line":241},[209,393,394],{"class":376},"  width",[209,396,380],{"class":237},[209,398,383],{"class":237},[209,400,401],{"class":257},"800",[209,403,389],{"class":237},[209,405,406,409,411,413,416],{"class":211,"line":268},[209,407,408],{"class":376},"  height",[209,410,380],{"class":237},[209,412,383],{"class":237},[209,414,415],{"class":257},"533",[209,417,389],{"class":237},[209,419,420,423,425,427,430],{"class":211,"line":279},[209,421,422],{"class":376},"  sizes",[209,424,380],{"class":237},[209,426,383],{"class":237},[209,428,429],{"class":257},"100vw sm:50vw md:400px",[209,431,389],{"class":237},[209,433,434,437,439,441,443],{"class":211,"line":293},[209,435,436],{"class":376},"  format",[209,438,380],{"class":237},[209,440,383],{"class":237},[209,442,305],{"class":257},[209,444,389],{"class":237},[209,446,447,450,452,454,457],{"class":211,"line":314},[209,448,449],{"class":376},"  alt",[209,451,380],{"class":237},[209,453,383],{"class":237},[209,455,456],{"class":257},"The team at work",[209,458,389],{"class":237},[209,460,461],{"class":211,"line":320},[209,462,463],{"class":233},"\u002F>\n",[13,465,466,467,470,471,474],{},"For AVIF with a fallback, use ",[141,468,469],{},"\u003CNuxtPicture format=\"avif,webp\">",". It outputs a ",[141,472,473],{},"\u003Cpicture>"," element with both formats and adds a JPEG or PNG fallback for older browsers.",[13,476,477,478,481,482,485],{},"Two smaller props are worth knowing. ",[141,479,480],{},"densities=\"x1 x2\""," serves sharper files to high-density screens without sending them to everyone else. ",[141,483,484],{},"quality"," trades file size against detail; 75 to 85 is a common range for photos, and this site uses 85 as its default.",[184,487,489],{"id":488},"nuxt-image-lazy-loading","Nuxt Image Lazy Loading",[13,491,492],{},"Nuxt image lazy loading isn't on by default. With Nuxt Image, you can lazy load anything below the fold by adding one attribute:",[200,494,496],{"className":359,"code":495,"language":361,"meta":205,"style":205},"\u003CNuxtImg src=\"\u002Fimages\u002Foffice.jpg\" width=\"600\" height=\"400\" loading=\"lazy\" alt=\"Our office\" \u002F>\n",[141,497,498],{"__ignoreMap":205},[209,499,500,502,505,508,510,512,515,517,520,522,524,527,529,532,534,536,539,541,544,546,548,551,553,556,558,560,563,565],{"class":211,"line":212},[209,501,368],{"class":237},[209,503,504],{"class":244},"NuxtImg",[209,506,507],{"class":376}," src",[209,509,380],{"class":237},[209,511,383],{"class":237},[209,513,514],{"class":257},"\u002Fimages\u002Foffice.jpg",[209,516,383],{"class":237},[209,518,519],{"class":376}," width",[209,521,380],{"class":237},[209,523,383],{"class":237},[209,525,526],{"class":257},"600",[209,528,383],{"class":237},[209,530,531],{"class":376}," height",[209,533,380],{"class":237},[209,535,383],{"class":237},[209,537,538],{"class":257},"400",[209,540,383],{"class":237},[209,542,543],{"class":376}," loading",[209,545,380],{"class":237},[209,547,383],{"class":237},[209,549,550],{"class":257},"lazy",[209,552,383],{"class":237},[209,554,555],{"class":376}," alt",[209,557,380],{"class":237},[209,559,383],{"class":237},[209,561,562],{"class":257},"Our office",[209,564,383],{"class":237},[209,566,567],{"class":237}," \u002F>\n",[13,569,570],{},"Don't do this for the LCP image, the largest one in the first screen. Lazy loading it delays your most important metric. Preload it instead, with a high fetch priority:",[200,572,574],{"className":359,"code":573,"language":361,"meta":205,"style":205},"\u003CNuxtImg\n  src=\"\u002Fimages\u002Fhero.jpg\"\n  width=\"1200\"\n  height=\"630\"\n  sizes=\"100vw lg:1200px\"\n  :preload=\"{ fetchPriority: 'high' }\"\n  alt=\"Product dashboard\"\n\u002F>\n",[141,575,576,582,595,608,621,634,667,680],{"__ignoreMap":205},[209,577,578,580],{"class":211,"line":212},[209,579,368],{"class":237},[209,581,371],{"class":244},[209,583,584,586,588,590,593],{"class":211,"line":219},[209,585,377],{"class":376},[209,587,380],{"class":237},[209,589,383],{"class":237},[209,591,592],{"class":257},"\u002Fimages\u002Fhero.jpg",[209,594,389],{"class":237},[209,596,597,599,601,603,606],{"class":211,"line":241},[209,598,394],{"class":376},[209,600,380],{"class":237},[209,602,383],{"class":237},[209,604,605],{"class":257},"1200",[209,607,389],{"class":237},[209,609,610,612,614,616,619],{"class":211,"line":268},[209,611,408],{"class":376},[209,613,380],{"class":237},[209,615,383],{"class":237},[209,617,618],{"class":257},"630",[209,620,389],{"class":237},[209,622,623,625,627,629,632],{"class":211,"line":279},[209,624,422],{"class":376},[209,626,380],{"class":237},[209,628,383],{"class":237},[209,630,631],{"class":257},"100vw lg:1200px",[209,633,389],{"class":237},[209,635,636,639,642,644,646,649,652,654,657,660,662,665],{"class":211,"line":293},[209,637,638],{"class":237},"  :",[209,640,641],{"class":376},"preload",[209,643,380],{"class":237},[209,645,383],{"class":237},[209,647,648],{"class":237},"{",[209,650,651],{"class":244}," fetchPriority",[209,653,248],{"class":237},[209,655,656],{"class":237}," '",[209,658,659],{"class":257},"high",[209,661,254],{"class":237},[209,663,664],{"class":237}," }",[209,666,389],{"class":237},[209,668,669,671,673,675,678],{"class":211,"line":314},[209,670,449],{"class":376},[209,672,380],{"class":237},[209,674,383],{"class":237},[209,676,677],{"class":257},"Product dashboard",[209,679,389],{"class":237},[209,681,682],{"class":211,"line":320},[209,683,463],{"class":233},[13,685,686,687,690],{},"This adds a ",[141,688,689],{},"\u003Clink rel=\"preload\">"," to the page head, so the browser starts the download before it reaches the image in the HTML.",[17,692,694],{"id":693},"how-to-reduce-javascript-in-nuxt","How to Reduce JavaScript in Nuxt",[13,696,697],{},"JavaScript has to be downloaded, parsed and run, and while the main thread is busy with it, clicks and taps wait. That wait is what INP measures.",[184,699,701],{"id":700},"analyze-the-bundle","Analyze the Bundle",[13,703,704],{},"Start by looking:",[200,706,710],{"className":707,"code":708,"language":709,"meta":205,"style":205},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","npx nuxt analyze\n","bash",[141,711,712],{"__ignoreMap":205},[209,713,714,718,721],{"class":211,"line":212},[209,715,717],{"class":716},"sBMFI","npx",[209,719,720],{"class":257}," nuxt",[209,722,723],{"class":257}," analyze\n",[13,725,726],{},"It builds the app and opens reports for the client and server bundles, with every dependency drawn to scale. Look for large libraries pulled into the entry chunk, full builds of date or chart libraries where a smaller import would do, and the same package bundled twice in different versions.",[184,728,730],{"id":729},"lazy-components-and-lazy-hydration","Lazy Components and Lazy Hydration",[13,732,733,734,737],{},"Add the ",[141,735,736],{},"Lazy"," prefix to any component and Nuxt loads its code only when it renders. Since Nuxt 3.16 you can also delay hydration, so server-rendered HTML shows straight away but the component's JavaScript runs later:",[200,739,741],{"className":359,"code":740,"language":361,"meta":205,"style":205},"\u003Ctemplate>\n  \u003CLazyProductReviews hydrate-on-visible \u002F>\n  \u003CLazyNewsletterForm hydrate-on-interaction \u002F>\n  \u003CLazyRelatedPosts hydrate-on-idle \u002F>\n\u003C\u002Ftemplate>\n",[141,742,743,753,766,778,790],{"__ignoreMap":205},[209,744,745,747,750],{"class":211,"line":212},[209,746,368],{"class":237},[209,748,749],{"class":244},"template",[209,751,752],{"class":237},">\n",[209,754,755,758,761,764],{"class":211,"line":219},[209,756,757],{"class":237},"  \u003C",[209,759,760],{"class":244},"LazyProductReviews",[209,762,763],{"class":376}," hydrate-on-visible",[209,765,567],{"class":237},[209,767,768,770,773,776],{"class":211,"line":241},[209,769,757],{"class":237},[209,771,772],{"class":244},"LazyNewsletterForm",[209,774,775],{"class":376}," hydrate-on-interaction",[209,777,567],{"class":237},[209,779,780,782,785,788],{"class":211,"line":268},[209,781,757],{"class":237},[209,783,784],{"class":244},"LazyRelatedPosts",[209,786,787],{"class":376}," hydrate-on-idle",[209,789,567],{"class":237},[209,791,792,795,797],{"class":211,"line":279},[209,793,794],{"class":237},"\u003C\u002F",[209,796,749],{"class":244},[209,798,752],{"class":237},[13,800,801,802,804],{},"The two do different jobs. ",[141,803,736],{}," splits the component's code into its own chunk, while the hydration props decide when that code runs on a server-rendered page.",[13,806,807,810,811,814,815,818,819,822],{},[141,808,809],{},"hydrate-on-visible"," waits until the component scrolls into view, ",[141,812,813],{},"hydrate-on-interaction"," waits for a click, focus or hover, and ",[141,816,817],{},"hydrate-on-idle"," waits until the browser has nothing else to do. There's also ",[141,820,821],{},"hydrate-never"," for static blocks that never need JavaScript. A good rule: anything below the fold that isn't needed for the first interaction can wait.",[184,824,826],{"id":825},"nuxt-minify-js-what-the-build-already-does","Nuxt Minify JS: What the Build Already Does",[13,828,829],{},"You don't need a plugin for Nuxt minify JS. A production build already minifies JavaScript and CSS, removes unused exports, and splits code so each page loads its own chunk. On Nuxt 4.5 and later, which build with Vite 8, the JavaScript minifier is Oxc and CSS goes through Lightning CSS.",[13,831,832,833,836],{},"What's left is up to you. Minification can't remove a library you import but barely use, code that runs on every page from a global plugin, or a component imported eagerly when it's needed on one route. Those are what ",[141,834,835],{},"nuxt analyze"," is for.",[17,838,840],{"id":839},"nuxt-js-performance-optimization-rendering-and-caching","Nuxt JS Performance Optimization: Rendering and Caching",[13,842,843,844,848],{},"The biggest Nuxt JS performance optimization is often not rendering the same page twice. If you're new to Nuxt's rendering modes, ",[159,845,847],{"href":846},"\u002Fblog\u002Fwhat-is-nuxt","What is Nuxt"," explains them. Route rules let you choose per path:",[200,850,852],{"className":202,"code":851,"language":204,"meta":205,"style":205},"\u002F\u002F nuxt.config.ts\nexport default defineNuxtConfig({\n  routeRules: {\n    '\u002F': { prerender: true },\n    '\u002Fblog\u002F**': { swr: 3600 },\n    '\u002Fproducts\u002F**': { isr: 600 },\n    '\u002Fdashboard\u002F**': { ssr: false },\n  },\n})\n",[141,853,854,858,870,879,906,929,952,975,979],{"__ignoreMap":205},[209,855,856],{"class":211,"line":212},[209,857,216],{"class":215},[209,859,860,862,864,866,868],{"class":211,"line":219},[209,861,223],{"class":222},[209,863,226],{"class":222},[209,865,230],{"class":229},[209,867,234],{"class":233},[209,869,238],{"class":237},[209,871,872,875,877],{"class":211,"line":241},[209,873,874],{"class":244},"  routeRules",[209,876,248],{"class":237},[209,878,276],{"class":237},[209,880,881,884,887,889,891,894,897,899,903],{"class":211,"line":268},[209,882,883],{"class":237},"    '",[209,885,886],{"class":244},"\u002F",[209,888,254],{"class":237},[209,890,248],{"class":237},[209,892,893],{"class":237}," {",[209,895,896],{"class":244}," prerender",[209,898,248],{"class":237},[209,900,902],{"class":901},"sfNiH"," true",[209,904,905],{"class":237}," },\n",[209,907,908,910,913,915,917,919,922,924,927],{"class":211,"line":279},[209,909,883],{"class":237},[209,911,912],{"class":244},"\u002Fblog\u002F**",[209,914,254],{"class":237},[209,916,248],{"class":237},[209,918,893],{"class":237},[209,920,921],{"class":244}," swr",[209,923,248],{"class":237},[209,925,926],{"class":287}," 3600",[209,928,905],{"class":237},[209,930,931,933,936,938,940,942,945,947,950],{"class":211,"line":293},[209,932,883],{"class":237},[209,934,935],{"class":244},"\u002Fproducts\u002F**",[209,937,254],{"class":237},[209,939,248],{"class":237},[209,941,893],{"class":237},[209,943,944],{"class":244}," isr",[209,946,248],{"class":237},[209,948,949],{"class":287}," 600",[209,951,905],{"class":237},[209,953,954,956,959,961,963,965,968,970,973],{"class":211,"line":314},[209,955,883],{"class":237},[209,957,958],{"class":244},"\u002Fdashboard\u002F**",[209,960,254],{"class":237},[209,962,248],{"class":237},[209,964,893],{"class":237},[209,966,967],{"class":244}," ssr",[209,969,248],{"class":237},[209,971,972],{"class":901}," false",[209,974,905],{"class":237},[209,976,977],{"class":211,"line":320},[209,978,317],{"class":237},[209,980,982,984],{"class":211,"line":981},9,[209,983,323],{"class":237},[209,985,326],{"class":233},[13,987,988,989,992,993,996,997,1000],{},"Prerendered pages are built once and served as files. ",[141,990,991],{},"swr"," caches the server response and refreshes it in the background after an hour. ",[141,994,995],{},"isr"," does the same on the CDN, on hosts that support it, such as Vercel and Netlify. ",[141,998,999],{},"ssr: false"," turns a section into a client-rendered app, which is fine behind a login and costly anywhere search engines or first-time visitors land.",[13,1002,1003,1004,1006],{},"Prerendering is the fastest option when it fits. This site prerenders every page with ",[141,1005,340],{},", so each request is a static file from the CDN with no server work at all. It fits any page whose content changes on publish rather than per visitor.",[13,1008,1009],{},"Slow APIs can be cached on the server too:",[200,1011,1013],{"className":202,"code":1012,"language":204,"meta":205,"style":205},"\u002F\u002F server\u002Fapi\u002Fproducts.get.ts\nexport default defineCachedEventHandler(async () => {\n  return await $fetch('https:\u002F\u002Fapi.example.com\u002Fproducts')\n}, { maxAge: 60 * 10 })\n",[141,1014,1015,1020,1042,1064],{"__ignoreMap":205},[209,1016,1017],{"class":211,"line":212},[209,1018,1019],{"class":215},"\u002F\u002F server\u002Fapi\u002Fproducts.get.ts\n",[209,1021,1022,1024,1026,1029,1031,1034,1037,1040],{"class":211,"line":219},[209,1023,223],{"class":222},[209,1025,226],{"class":222},[209,1027,1028],{"class":229}," defineCachedEventHandler",[209,1030,234],{"class":233},[209,1032,1033],{"class":376},"async",[209,1035,1036],{"class":237}," ()",[209,1038,1039],{"class":376}," =>",[209,1041,276],{"class":237},[209,1043,1044,1047,1050,1053,1055,1057,1060,1062],{"class":211,"line":241},[209,1045,1046],{"class":222},"  return",[209,1048,1049],{"class":222}," await",[209,1051,1052],{"class":229}," $fetch",[209,1054,234],{"class":244},[209,1056,254],{"class":237},[209,1058,1059],{"class":257},"https:\u002F\u002Fapi.example.com\u002Fproducts",[209,1061,254],{"class":237},[209,1063,326],{"class":244},[209,1065,1066,1069,1071,1074,1076,1079,1082,1085,1087],{"class":211,"line":268},[209,1067,1068],{"class":237},"},",[209,1070,893],{"class":237},[209,1072,1073],{"class":244}," maxAge",[209,1075,248],{"class":237},[209,1077,1078],{"class":287}," 60",[209,1080,1081],{"class":237}," *",[209,1083,1084],{"class":287}," 10",[209,1086,664],{"class":237},[209,1088,326],{"class":233},[13,1090,1091,1092,1095],{},"Last, watch the payload. Whatever ",[141,1093,1094],{},"useFetch"," returns on the server is serialized into the page for hydration, so send only what the template uses:",[200,1097,1099],{"className":202,"code":1098,"language":204,"meta":205,"style":205},"const { data: products } = await useFetch('\u002Fapi\u002Fproducts', {\n  transform: items => items.map(({ id, title, price }) => ({ id, title, price })),\n})\n",[141,1100,1101,1140,1207],{"__ignoreMap":205},[209,1102,1103,1106,1108,1111,1113,1116,1118,1121,1123,1126,1128,1130,1133,1135,1138],{"class":211,"line":212},[209,1104,1105],{"class":376},"const",[209,1107,893],{"class":237},[209,1109,1110],{"class":244}," data",[209,1112,248],{"class":237},[209,1114,1115],{"class":233}," products ",[209,1117,323],{"class":237},[209,1119,1120],{"class":237}," =",[209,1122,1049],{"class":222},[209,1124,1125],{"class":229}," useFetch",[209,1127,234],{"class":233},[209,1129,254],{"class":237},[209,1131,1132],{"class":257},"\u002Fapi\u002Fproducts",[209,1134,254],{"class":237},[209,1136,1137],{"class":237},",",[209,1139,276],{"class":237},[209,1141,1142,1145,1147,1151,1153,1155,1158,1161,1163,1166,1169,1171,1174,1176,1179,1182,1184,1187,1189,1191,1193,1195,1197,1200,1202,1205],{"class":211,"line":219},[209,1143,1144],{"class":229},"  transform",[209,1146,248],{"class":237},[209,1148,1150],{"class":1149},"sHdIc"," items",[209,1152,1039],{"class":376},[209,1154,1150],{"class":233},[209,1156,1157],{"class":237},".",[209,1159,1160],{"class":229},"map",[209,1162,234],{"class":233},[209,1164,1165],{"class":237},"({",[209,1167,1168],{"class":1149}," id",[209,1170,1137],{"class":237},[209,1172,1173],{"class":1149}," title",[209,1175,1137],{"class":237},[209,1177,1178],{"class":1149}," price",[209,1180,1181],{"class":237}," })",[209,1183,1039],{"class":376},[209,1185,1186],{"class":233}," (",[209,1188,648],{"class":237},[209,1190,1168],{"class":233},[209,1192,1137],{"class":237},[209,1194,1173],{"class":233},[209,1196,1137],{"class":237},[209,1198,1199],{"class":233}," price ",[209,1201,323],{"class":237},[209,1203,1204],{"class":233},"))",[209,1206,265],{"class":237},[209,1208,1209,1211],{"class":211,"line":241},[209,1210,323],{"class":237},[209,1212,326],{"class":233},[13,1214,1215,1216,1219],{},"For a single object, the ",[141,1217,1218],{},"pick"," option does the same with a list of keys. Nuxt 4.6 also warns in development when a page's payload goes over 100 kB.",[17,1221,1223],{"id":1222},"fonts-and-third-party-scripts","Fonts and Third-Party Scripts",[13,1225,1226,1227,1230],{},"Web fonts delay text and shift the layout when they swap in. The ",[141,1228,1229],{},"@nuxt\u002Ffonts"," module downloads fonts at build time, serves them from your own domain with long cache headers, and generates a fallback font sized to match, so the swap barely moves anything. We use it on this site for Manrope.",[13,1232,1233,1234,1237,1238,1241],{},"Third-party scripts such as analytics, chat and video embeds are often the heaviest JavaScript on a page, and you don't control them. ",[141,1235,1236],{},"@nuxt\u002Fscripts"," loads them after hydration by default, can wait for cookie consent or for an element to scroll into view, and ships facade components. ",[141,1239,1240],{},"\u003CScriptYouTubePlayer>"," shows a thumbnail and loads the YouTube player only when someone interacts with it.",[17,1243,1245],{"id":1244},"conclusion","Conclusion",[13,1247,1248],{},"Check field data first, then work down the list: the LCP image, JavaScript, caching, fonts and scripts. Re-measure after each step, not at the end, so you know which fix did the work.",[13,1250,1251,1252,1256,1257,1157],{},"If your scores still won't move, our ",[159,1253,1255],{"href":1254},"\u002Fservices\u002Ffrontend-performance","Vue and Nuxt performance optimization services"," find the bottlenecks, rank them by expected impact and implement the fixes in your codebase. For new builds and upgrades, see our ",[159,1258,1260],{"href":1259},"\u002Fservices\u002Fnuxt-development","Nuxt development services",[17,1262,1264],{"id":1263},"faqs","FAQs",[184,1266,1268],{"id":1267},"does-nuxt-image-lazy-load-by-default","Does Nuxt Image lazy load by default?",[13,1270,1271,1272,1275],{},"No. NuxtImg renders a normal img tag, and you opt in with ",[141,1273,1274],{},"loading=\"lazy\"",". That's deliberate, because the largest image above the fold should load as early as possible, not wait for the browser to decide it's visible.",[184,1277,1279],{"id":1278},"does-nuxt-image-work-with-a-cdn","Does Nuxt Image work with a CDN?",[13,1281,1282],{},"Yes. Nuxt Image ships with providers for more than 40 image services and CDNs, including Cloudinary, Cloudflare, imgix, Vercel and Netlify, and it detects Vercel, Netlify and AWS Amplify automatically. You keep the same NuxtImg markup and the provider builds the URLs.",[184,1284,1286],{"id":1285},"how-do-i-reduce-nuxt-bundle-size","How do I reduce Nuxt bundle size?",[13,1288,1289,1290,1293],{},"Run ",[141,1291,1292],{},"npx nuxt analyze"," to see what's in each chunk, then replace or lazy-load the biggest dependencies. Use Lazy components and lazy hydration for anything below the fold, and load third-party scripts through Nuxt Scripts instead of plugins.",[184,1295,1297],{"id":1296},"does-ssr-make-a-nuxt-app-faster","Does SSR make a Nuxt app faster?",[13,1299,1300],{},"It makes the first view faster, because the browser gets finished HTML instead of an empty page and a bundle to run. It doesn't make interactions faster, and a slow server can cancel the gain, so cache or prerender pages where you can.",[184,1302,1304],{"id":1303},"is-nuxt-faster-than-plain-vue","Is Nuxt faster than plain Vue?",[13,1306,1307,1308,1312],{},"For public pages, usually yes on first load, because Nuxt sends server-rendered or prerendered HTML while a plain Vue SPA renders in the browser. After that both run the same Vue runtime, so interaction speed depends on your code, not the framework. Our ",[159,1309,1311],{"href":1310},"\u002Fblog\u002Fnuxt-vs-vue","Nuxt vs Vue"," comparison covers the rest of the difference.",[184,1314,1316],{"id":1315},"does-upgrading-to-nuxt-4-improve-performance","Does upgrading to Nuxt 4 improve performance?",[13,1318,1319,1320,1324],{},"Mostly in development: Nuxt 4 starts faster and shares data between components that use the same key. Production speed depends more on your images, JavaScript and caching. The stronger reason to upgrade is support, since Nuxt 3 reached end of life on 31 July 2026. Our ",[159,1321,1323],{"href":1322},"\u002Fblog\u002Fnuxt4-migration","Nuxt 4 migration guide"," walks through the changes.",[184,1326,1328],{"id":1327},"when-does-a-nuxt-app-need-a-performance-audit","When does a Nuxt app need a performance audit?",[13,1330,1331,1332,1336],{},"When Core Web Vitals fail in field data, when conversion drops on mobile, or before a big redesign or migration. An audit is also worth it when the team has tried the obvious fixes and scores still don't move. Our ",[159,1333,1335],{"href":1334},"\u002Fservices\u002Fcode-audit","Vue and Nuxt code audit"," covers performance alongside code quality.",[1338,1339,1340],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}",{"title":205,"searchDepth":241,"depth":241,"links":1342},[1343,1344,1345,1350,1355,1356,1357,1358],{"id":19,"depth":219,"text":20},{"id":135,"depth":219,"text":136},{"id":166,"depth":219,"text":167,"children":1346},[1347,1348,1349],{"id":186,"depth":241,"text":187},{"id":344,"depth":241,"text":345},{"id":488,"depth":241,"text":489},{"id":693,"depth":219,"text":694,"children":1351},[1352,1353,1354],{"id":700,"depth":241,"text":701},{"id":729,"depth":241,"text":730},{"id":825,"depth":241,"text":826},{"id":839,"depth":219,"text":840},{"id":1222,"depth":219,"text":1223},{"id":1244,"depth":219,"text":1245},{"id":1263,"depth":219,"text":1264,"children":1359},[1360,1361,1362,1363,1364,1365,1366],{"id":1267,"depth":241,"text":1268},{"id":1278,"depth":241,"text":1279},{"id":1285,"depth":241,"text":1286},{"id":1296,"depth":241,"text":1297},{"id":1303,"depth":241,"text":1304},{"id":1315,"depth":241,"text":1316},{"id":1327,"depth":241,"text":1328},null,"2026-11-20","Nuxt JS performance optimization tips: Nuxt Image optimization and lazy loading, bundle size, minifying JS, caching, and how to measure it.","md",[1372,1374,1375,1377,1378,1380,1382],{"question":1268,"answer":1373},"No. NuxtImg renders a normal img tag, and you opt in with loading=\"lazy\". That's deliberate, because the largest image above the fold should load as early as possible, not wait for the browser to decide it's visible.",{"question":1279,"answer":1282},{"question":1286,"answer":1376},"Run npx nuxt analyze to see what's in each chunk, then replace or lazy-load the biggest dependencies. Use Lazy components and lazy hydration for anything below the fold, and load third-party scripts through Nuxt Scripts instead of plugins.",{"question":1297,"answer":1300},{"question":1304,"answer":1379},"For public pages, usually yes on first load, because Nuxt sends server-rendered or prerendered HTML while a plain Vue SPA renders in the browser. After that both run the same Vue runtime, so interaction speed depends on your code, not the framework. Our Nuxt vs Vue comparison covers the rest of the difference.",{"question":1316,"answer":1381},"Mostly in development: Nuxt 4 starts faster and shares data between components that use the same key. Production speed depends more on your images, JavaScript and caching. The stronger reason to upgrade is support, since Nuxt 3 reached end of life on 31 July 2026. Our Nuxt 4 migration guide walks through the changes.",{"question":1328,"answer":1383},"When Core Web Vitals fail in field data, when conversion drops on mobile, or before a big redesign or migration. An audit is also worth it when the team has tried the obvious fixes and scores still don't move. Our Vue and Nuxt code audit covers performance alongside code quality.",false,"\u002Fimages\u002Fblog\u002Fnuxt-performance-optimization\u002Fcard.png",{},true,"\u002Fblog\u002Fnuxt-performance-optimization","10 min read",{"title":5,"description":1369},"blog\u002Fnuxt-performance-optimization",[1393,1394],"Nuxt","Performance","1VrlUAbUceqN_bDalkGUk779pShsO0ukM1yLpAmAZBE",1795177918174]