<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebDataSource/addSubresource(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WebDataSource(im)addSubresource:"
  },
  "title" : "addSubresource(_:)"
}
-->

# addSubresource(_:)

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

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

## Parameters

`subresource`

The resource to add to the data source.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)