# Lazy loading

# Lazy loading

Lazy loading enables pages to load faster, reduces resource consumption and
contention, and improves viewability rate by pausing the requesting and
rendering of ads until they approach the user's viewport.

With lazy loading in SRA, when the first ad slot comes within the viewport
specified by the [`fetchMarginPercent`](https://developers.google.com/publisher-tag/reference#googletag.config.LazyLoadConfig.fetchMarginPercent) property,
the call for that ad and all other ad slots is made.

## Sample implementation

[View demo](https://googleads.github.io/google-publisher-tag-samples/lazy-loading/js/demo.html)

> [!IMPORTANT]
> This sample makes use of library features that are not fully supported when running in an iframe. To view a demo of this sample in a new window, click the **View demo** button above.

### JavaScript

## Loading...

<iframe id="builder" class="fixed-size" loading="lazy"></iframe>

## Loading...

[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/lazy-loading/js) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback:+lazy-loading/js)

### TypeScript

## Loading...

<iframe id="builder" class="fixed-size" loading="lazy"></iframe>

## Loading...

[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/lazy-loading/ts) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback:+lazy-loading/ts)