> ## Documentation Index
> Fetch the complete documentation index at: https://autorender.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Hero and LCP

> Preload your largest image so Autorender Native never delays Largest Contentful Paint — the one pattern to hand-build instead of marking with data-ar-src.

Your largest image — the hero — should load the instant the page parses, before any script runs. Autorender Native measures and requests images from JavaScript, so it always starts a fraction later than the browser's own preload scanner. For the single Largest Contentful Paint element, hand-build the delivery URL instead of marking it, so the browser fetches it during HTML parsing.

## Why can't Native preload the hero?

The browser's preload scanner reads the raw HTML and starts fetching images before scripts execute. It looks at `src` and `srcset`, not `data-ar-src`. An element marked with `data-ar-src` has no source at parse time, so the scanner skips it and the fetch waits for the runtime.

`data-ar-eager` skips lazy loading, but it does not fix this — the source still appears only after the script runs. With [`debug=1`](/docs/native/configuration) an eager image with no parse-time source logs:

```
Eager image has no parse-time src and may delay LCP.
```

So for the LCP image, and only that image, skip Native and set a real source the scanner can see.

## Build and preload the hero

The runtime ignores any `<img>` without `data-ar-src`, so a hand-built hero coexists with marked images on the same page — no double fetch.

<Steps>
  <Step title="Pick a delivery width.">
    Multiply the hero's rendered CSS width by the device pixel ratio you want to serve, then cap the result at the image's real source width. You are building this URL by hand, so the runtime's [`max-dpr`](/docs/native/configuration) does not apply. A hero rendered at **1600 px** and served at **2×** asks for **3200 px**; if the source is only **2400 px** wide, cap it there and request `w_2400`.
  </Step>

  <Step title="Build the delivery URL by hand.">
    Use the standard [URL anatomy](/docs/introduction) — delivery domain, workspace ID, transforms, source path:

    ```
    https://assets.autorender.io/LOKVTtKVGb/w_2400/heroes/banner.jpg
    ```
  </Step>

  <Step title="Preload it in the head with high priority.">
    ```html wrap theme={null}
    <head>
      <link
        rel="preload"
        as="image"
        href="https://assets.autorender.io/LOKVTtKVGb/w_2400/heroes/banner.jpg"
        fetchpriority="high"
      />
      <script defer src="https://cdn.autorender.io/native/v1/native.min.js?ws=LOKVTtKVGb"></script>
    </head>
    ```
  </Step>

  <Step title="Use the same URL as a real src — no data-ar-src.">
    ```html wrap theme={null}
    <img
      src="https://assets.autorender.io/LOKVTtKVGb/w_2400/heroes/banner.jpg"
      width="1600"
      height="900"
      fetchpriority="high"
      alt="Autumn collection hero"
    />
    ```

    Because there is no `data-ar-src`, the runtime leaves this element alone. The browser reuses the preloaded fetch only when the `<link>` and the `<img>` match exactly — identical `href`, and `crossorigin` set on neither or on both. Any mismatch downloads your largest image twice, the exact failure this page exists to prevent.
  </Step>
</Steps>

<Warning>
  Do not put both `data-ar-src` and a real `src` on the hero. The browser fetches the real `src` in full during parsing, then the runtime overwrites it with its own variant — two downloads of your largest image. Either hand-build the hero (this page) or mark it and accept the later, script-driven fetch.
</Warning>

## Mark the rest of the page normally

Every image below the fold stays on the `data-ar-src` path. Only the LCP element needs the hand-built treatment.

```html {2} theme={null}
<!-- Hero: hand-built, preloaded, no data-ar-src -->
<img src="https://assets.autorender.io/LOKVTtKVGb/w_2400/heroes/banner.jpg" width="1600" height="900" fetchpriority="high" alt="Autumn collection hero" />

<!-- Everything else: marked, lazy, right-sized by the runtime -->
<img data-ar-src="products/chair.jpg" width="800" height="600" alt="Modern lounge chair" />
```

## What if JavaScript is disabled?

A marked `<img>` has no source until the runtime runs, so it shows nothing when JavaScript is off. Give any image you cannot afford to lose a `<noscript>` fallback with a hand-built URL:

```html wrap theme={null}
<noscript>
  <img
    src="https://assets.autorender.io/LOKVTtKVGb/w_800/products/chair.jpg"
    width="800"
    height="600"
    alt="Modern lounge chair"
  />
</noscript>
```

The hand-built hero needs no `<noscript>` — it already has a real `src` that works without the runtime.

## Next steps

<CardGroup cols={2}>
  <Card title="Attributes" icon="code" iconType="solid" href="/docs/native/attributes">
    Mark the rest of your images, backgrounds, and galleries.
  </Card>

  <Card title="Transformations" icon="wand-magic-sparkles" iconType="solid" href="/docs/transformations/introduction">
    Every token you can put in a hand-built hero URL.
  </Card>

  <Card title="Troubleshooting" icon="stethoscope" iconType="solid" href="/docs/native/troubleshooting">
    Diagnose a slow hero and other load problems from the console.
  </Card>

  <Card title="Configuration" icon="sliders" iconType="solid" href="/docs/native/configuration">
    Set `max-dpr`, width `step`, and the lazy-load lookahead from the script URL.
  </Card>
</CardGroup>
