---
title: "addSubresource(_:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webdatasource/addsubresource(_:)"
---

# addSubresource(_:)

Adds a resource to the data source’s list of subresources.

## Declaration

```swift
func addSubresource(_ subresource: WebResource!)
```

## Parameters

- `subresource`: The resource to add to the data source.

## Discussion

Discussion If the data source needs to reload the resource’s URL, it loads the data from subresource instead of the network. For example, use this method if you want to use a previously downloaded image rather than accessing the network to reload a resource. If the data source already has a resource with the same URL as subresource, then this method replaces it.

## See Also

### Accessing subresources

- [mainResource](webkit/webdatasource/mainresource.md)
- [subresource(for:)](webkit/webdatasource/subresource(for:).md)
- [subresources](webkit/webdatasource/subresources.md)
