mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Automatically download ResizeObserver polyfill when necessary
This commit is contained in:
parent
6b1d845904
commit
54bef7bfe5
@ -16,8 +16,8 @@ version range, please [open an issue]:
|
|||||||
|
|
||||||
<figure markdown>
|
<figure markdown>
|
||||||
|
|
||||||
| Browser | Version[^2] | Release date | | | Usage |
|
| Browser | Version | Release date | | | Usage |
|
||||||
| ------------------------------------ | ----------: | -----------: | ------: | -----: | ---------: |
|
| ------------------------------------ | ------: | -----------: | ------: | -----: | ---------: |
|
||||||
| | | | desktop | mobile | overall |
|
| | | | desktop | mobile | overall |
|
||||||
| :fontawesome-brands-chrome: Chrome | 49+ | 03/2016 | 25.65% | 38.33% | 63.98% |
|
| :fontawesome-brands-chrome: Chrome | 49+ | 03/2016 | 25.65% | 38.33% | 63.98% |
|
||||||
| :fontawesome-brands-safari: Safari | 10+ | 09/2016 | 4.63% | 14.96% | 19.59% |
|
| :fontawesome-brands-safari: Safari | 10+ | 09/2016 | 4.63% | 14.96% | 19.59% |
|
||||||
@ -40,23 +40,6 @@ Browser support matrix sourced from [caniuse.com].[^1]
|
|||||||
cumulated market share of less than 1% were not considered, but might still
|
cumulated market share of less than 1% were not considered, but might still
|
||||||
be fully or partially supported.
|
be fully or partially supported.
|
||||||
|
|
||||||
[^2]:
|
|
||||||
In Material for MkDocs 9.2.0, polyfills for ancient browsers were removed,
|
|
||||||
so make sure to add them back if you need to support the full version
|
|
||||||
range as mentioned in the [browser support] matrix. Add the following
|
|
||||||
lines to `mkdocs.yml`:
|
|
||||||
|
|
||||||
``` yaml
|
|
||||||
config:
|
|
||||||
extra:
|
|
||||||
polyfills:
|
|
||||||
- https://unpkg.com/resize-observer-polyfill
|
|
||||||
- https://unpkg.com/array-flat-polyfill
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also download the files and self-host them, or use the
|
|
||||||
[built-in privacy plugin] to do it automatically.
|
|
||||||
|
|
||||||
Note that the usage data is based on global browser market share, so it could
|
Note that the usage data is based on global browser market share, so it could
|
||||||
in fact be entirely different for your target demographic. It's a good idea to
|
in fact be entirely different for your target demographic. It's a good idea to
|
||||||
check the distribution of browser types and versions among your users.
|
check the distribution of browser types and versions among your users.
|
||||||
|
File diff suppressed because one or more lines are too long
18
material/.overrides/assets/javascripts/custom.a2f5d53d.min.js
vendored
Normal file
18
material/.overrides/assets/javascripts/custom.a2f5d53d.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -23,5 +23,5 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script src="{{ 'assets/javascripts/custom.99dda5c2.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/custom.a2f5d53d.min.js' | url }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
29
material/assets/javascripts/bundle.c1c13a0d.min.js
vendored
Normal file
29
material/assets/javascripts/bundle.c1c13a0d.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -250,7 +250,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.f11ae8b1.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.c1c13a0d.min.js' | url }}"></script>
|
||||||
{% for path in config.extra_javascript %}
|
{% for path in config.extra_javascript %}
|
||||||
{% if path.endswith(".mjs") %}
|
{% if path.endswith(".mjs") %}
|
||||||
<script type="module" src="{{ path | url }}"></script>
|
<script type="module" src="{{ path | url }}"></script>
|
||||||
|
@ -36,6 +36,8 @@ import {
|
|||||||
tap
|
tap
|
||||||
} from "rxjs"
|
} from "rxjs"
|
||||||
|
|
||||||
|
import { watchScript } from "../../../script"
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* Types
|
* Types
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
@ -65,15 +67,23 @@ const entry$ = new Subject<ResizeObserverEntry>()
|
|||||||
* It's quite important to centralize observation in a single `ResizeObserver`,
|
* It's quite important to centralize observation in a single `ResizeObserver`,
|
||||||
* as the performance difference can be quite dramatic, as the link shows.
|
* as the performance difference can be quite dramatic, as the link shows.
|
||||||
*
|
*
|
||||||
|
* If the browser doesn't have a `ResizeObserver` implementation available, a
|
||||||
|
* polyfill is automatically downloaded from unpkg.com. This is also compatible
|
||||||
|
* with the built-in privacy plugin, which will download the polyfill and put
|
||||||
|
* it alongside the built site for self-hosting.
|
||||||
|
*
|
||||||
* @see https://bit.ly/3iIYfEm - Google Groups on performance
|
* @see https://bit.ly/3iIYfEm - Google Groups on performance
|
||||||
*/
|
*/
|
||||||
const observer$ = defer(() => of(
|
const observer$ = defer(() => (
|
||||||
new ResizeObserver(entries => {
|
typeof ResizeObserver === "undefined"
|
||||||
|
? watchScript("https://unpkg.com/resize-observer-polyfill")
|
||||||
|
: of(undefined)
|
||||||
|
))
|
||||||
|
.pipe(
|
||||||
|
map(() => new ResizeObserver(entries => {
|
||||||
for (const entry of entries)
|
for (const entry of entries)
|
||||||
entry$.next(entry)
|
entry$.next(entry)
|
||||||
})
|
})),
|
||||||
))
|
|
||||||
.pipe(
|
|
||||||
switchMap(observer => merge(NEVER, of(observer))
|
switchMap(observer => merge(NEVER, of(observer))
|
||||||
.pipe(
|
.pipe(
|
||||||
finalize(() => observer.disconnect())
|
finalize(() => observer.disconnect())
|
||||||
|
Loading…
Reference in New Issue
Block a user