new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Nuxt · API · all subjects

utils/preload-route-components

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

preloadRouteComponents utility function

preloadRouteComponents allows you to manually preload individual pages in your Nuxt app. Preloading routes loads the components of a given route that the user might navigate to in future. This ensures that the components are available earlier and less likely to block the navigation, improving performance. The function takes a route path as a parameter (for example, '/dashboard'). It is a non-blocking async function that should not be awaited in component setup functions to avoid blocking rendering. On the server, preloadRouteComponents will have no effect.

preloadRouteComponents example with navigateTo

This example shows preloading a route when using navigateTo. The preloadRouteComponents function is called without awaiting to avoid blocking rendering in the component's setup function. After authentication results are received, navigateTo is called to navigate to the preloaded route. ```ts // we don't await this async function, to avoid blocking rendering // this component's setup function preloadRouteComponents('/dashboard') const submit = async () => { const results = await $fetch('/api/authentication') if (results.token) { await navigateTo('/dashboard') } } ```

NuxtLink automatically preloads routes

Nuxt already automatically preloads the necessary routes if you are using the NuxtLink component, so manual preloading with preloadRouteComponents may not always be necessary for links.

Give your agent this brain