Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simplify script inclusion when using same domain #206

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ To do it, simply add the following script to your pages.
```html
<script defer type="text/javascript" src="https://rum.hlx.page/.rum/@adobe/helix-rum-js@^2/dist/rum-standalone.js"></script>
```

If you want to instruct a 404 response, include this script instead in standalone mode.
```html
<script defer type="text/javascript" src="https://rum.hlx.page/.rum/@adobe/helix-rum-js@^2/dist/rum-standalone-404.js"></script>
```

If you understand the details of a high performance page, it might be advisable to load the script after the [LCP](https://web.dev/articles/lcp) event

Check the following link for [advanced configuration options](docs/STANDALONE-ADVANCED-CONFIG.md).
Expand Down
8 changes: 7 additions & 1 deletion docs/STANDALONE-ADVANCED-CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ You can pin a specific version number by using a URL like `https://rum.hlx.page/
## Customizing Origin for extra scripts and data collection

If you use RUM in an standalone mode and you want to minimize the performance impact, you could route RUM requests via the same domain that serves your website.
You could achieve that it by setting the global variable `window.RUM_BASE` before loading the script.
In this case, simply load the standalone script from the same domain and all RUM requests are routed through the same domain.
```
<script defer type="text/javascript" src="/.rum/@adobe/helix-rum-js@^2/dist/rum-standalone.js"/>
```

Please note, that the origin you set, must route `/.rum/*` requests to `https://rum.hlx.page/.rum/*`

For more complex setups, a different option is to set the global variable `window.RUM_BASE` before loading the script. All RUM requests will then use that domain.

E.g.
```javascript
window.RUM_BASE = window.origin;
Expand Down
Loading