You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dev-docs/modules/index.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,49 @@ results. See [the userSync setConfig](/dev-docs/publisher-api-reference/setConfi
115
115
</tbody>
116
116
</table>
117
117
118
+
## Loading modules separately
119
+
120
+
There are situations where a publisher uses different modules depending on various factors, such as specific pages or locations. This creates the inconvenience of having to load a Prebid build that is larger than what a particular page actually needs. While it’s possible to work around this by creating separate Prebid builds for different pages, that approach doesn’t scale well. Since a Prebid build is composed of concatenated chunks, it’s possible to load modules separately, allowing you to have a main Prebid file that contains only the modules shared across all pages.
121
+
122
+
### Example
123
+
124
+
This is the example of loading modules separately for the self-hosted (e.g. CDN) Prebid build.
125
+
Instructions for importing modules when using the npm package can be found in the [Readme file](https://github.com/prebid/Prebid.js/blob/master/README.md)
126
+
127
+
1. Perform full Prebid build `gulp build`
128
+
1. Generate the main `prebid.js` file containing only the modules required across all pages: `gulp bundle --modules=<...>`
129
+
1. Host `build/dist` folder content on your server or CDN
130
+
1. Check the dependencies of the modules you plan to load dynamically on the current page [Dependency tree](https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/chunks/dependencies.json)
131
+
1. Load the required modules, their dependencies using script tags:
132
+
133
+
```html
134
+
<html>
135
+
<head>
136
+
<title>Page 1</title>>
137
+
<scriptsrc="https://<your-cdn>/prebid/ortbConverter.js"></script> <!-- Depedency of openxBidAdapter !-->
<scriptsrc="https://<your-cdn>/prebid/id5IdSystem.js"></script> <!-- Another module (doesn't require any additional dependencies) !-->
140
+
<scriptsrc="https://<your-cdn>/prebid/prebid.js"></script> <!-- Load prebid.js last !-->
141
+
</head>
142
+
```
143
+
144
+
### Storage control usage
145
+
146
+
When working with the `storageControl` module you will need to explicitly import disclosure metadata. To do this, pair each module import with its corresponding metadata file `<module>.metadata.js`
147
+
148
+
```html
149
+
<html>
150
+
<head>
151
+
<title>Page 1</title>>
152
+
<scriptsrc="https://<your-cdn>/prebid/ortbConverter.js"></script> <!-- Depedency of openxBidAdapter !-->
0 commit comments