Performance: Error pages (+error.svelte)
This affects the page load speed and user experience when an error occurs, impacting how quickly the error content is shown and how stable the layout remains.
<script> export let error; </script> <section aria-live="assertive" role="alert"> <h1>{error.status}</h1> <p>{error.message}</p> </section>
<script> import HeavyComponent from '../components/HeavyComponent.svelte'; export let error; </script> <HeavyComponent /> <h1>{error.status}</h1> <p>{error.message}</p>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy component on error page | High (many nodes) | Multiple reflows | High paint cost | [X] Bad |
| Minimal markup with semantic HTML | Low (few nodes) | Single reflow | Low paint cost | [OK] Good |
+error.svelte file in a SvelteKit project?+error.svelte+error.svelte.+error.svelte [OK]+error.svelte shows errors, not routes or styles [OK]+error.svelte handles authentication+error.svelte?+error.svelte, the status is passed as a separate prop, not inside error.{error.status} is incorrect because error holds the error object, but status is separate. {status} is correct. {error.message} is for the message, not status. {params.status} is unrelated.{status} [OK]+error.svelte snippet:<script>
export let error;
export let status;
</script>
<h1>Error {status}</h1>
<p>{error.message}</p>status is 404 and error.message is "Page not found"?{status} is 404, so <h1> shows "Error 404". The {error.message} is "Page not found", so <p> shows that text.+error.svelte code:<script>
export let error;
</script>
<h1>Error {status}</h1>
<p>{error.message}</p>Error undefined. What is the problem?{status} but does not export status from the script, so it is undefined.{error.status} is incorrect because status is a separate prop. Importing status is not needed. error.message exists, so that is not the issue.status prop -> Option C+error.svelte code correctly implements this?status === 404 is correct. <script>
export let error;
export let status;
</script>
<h1>Error {status}</h1>
<p>{status === 404 ? 'Page not found' : error.message}</p> and D do this, but D compares to string '404' which is wrong.<script>
export let error;
export let status;
</script>
<h1>Error {status}</h1>
<p>{status === 404 ? 'Page not found' : error.message}</p> uses error.message as fallback, which is correct. Options B and C incorrectly compare error.message to 404, which makes no sense.<script>
export let error;
export let status;
</script>
<h1>Error {status}</h1>
<p>{status === 404 ? 'Page not found' : error.message}</p> correctly exports both props and uses a ternary to show special message for 404, else shows error.message.Pass the test and this pattern moves unknown