Skip to content

Commit 2ef306f

Browse files
committed
Add note on unsupported browsers
Firefox and Safari expose very few of these signals, so it’s important that developers build accordingly. This should, hopefully, nudge them in the right direction.
1 parent 36fbefa commit 2ef306f

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ Copy/paste the following as close to the top of your `<head>` as possible:
124124
</script>
125125
```
126126

127-
Or download the [latest minified version](https://github.com/csswizardry/Obs.js/releases/latest).
127+
Or download the [latest minified
128+
version](https://github.com/csswizardry/Obs.js/releases/latest).
128129

129130
### Listen for Changes
130131

@@ -219,3 +220,34 @@ Obs.js also stores the following properties on the `window.obs` object:
219220
| `cpuBucket` | number (cores) | 1-core bucket (integer cores) | `navigator.hardwareConcurrency` | Prefer `cpuCategory` for segmentation |
220221
| `cpuCategory` | `'low'` \| `'medium'` \| `'high'` | CPU tier | From cores (≤ 2 = low, 3–5 = medium, ≥ 6 = high) | Adds `.has-cpu-*` classes |
221222
| `deviceCapability` | `'strong'` \| `'moderate'` \| `'weak'` | Device capability stance | From `ramCategory` and `cpuCategory` | **strong** when CPU is **high** **and** RAM is **medium/high**; **weak** when RAM is **very-low/low** **or** CPU is **low**; otherwise **moderate**. Adds matching classes. |
223+
224+
## Unsupported Browsers
225+
226+
Most of these APIs are only available in Chromium browsers. This means you need
227+
to decide how to handle notable absentees like iOS yourself: Obs.js does not
228+
make opinionated decisions for you.
229+
230+
Your choices are:
231+
232+
1. Always ship the rich version to Safari, or;
233+
2. Always ship the lite version to Safari.
234+
235+
You can write your `if`s and `else`s to accommodate either.
236+
237+
```js
238+
if (window.obs?.shouldAvoidRichMedia === true) {
239+
// Serve lite version to slow supportive browsers.
240+
} else {
241+
// Serve rich version to fast supportive browsers and Safari.
242+
}
243+
```
244+
245+
```js
246+
if (window.obs?.canShowRichMedia === true) {
247+
// Serve rich version to fast supportive browsers.
248+
} else {
249+
// Serve lite version to slow supportive browsers and Safari.
250+
}
251+
```
252+
253+
The choice is yours.

0 commit comments

Comments
 (0)