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: packages/lit-dev-content/site/guide/getting-started.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -323,9 +323,7 @@ If you already have a dev server that works with your build system, it should wo
323
323
324
324
### Supporting older browsers
325
325
326
-
To support older browsers that don't support ES6 and the web components specifications, you'll need to take a few extra steps to produce code that will run on the older browsers.
327
-
328
-
See [Build for production](build) for more information.
326
+
For older browsers like Internet Explorer 11 that don't support ES2020 and web components natively, see [Tools and Workflows](/guide/tools/overview) for information about setting up Lit to work for testing, development, building, and publishing.
Copy file name to clipboardExpand all lines: packages/lit-dev-content/site/guide/tools/requirements.md
+89-6Lines changed: 89 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,17 @@ Webpack automatically handles bare module specifiers; for Rollup, you'll need a
31
31
32
32
**Why bare module specifiers?** Bare module specifiers let you import modules without knowing exactly where the package manager has installed them. A standards proposal called [Import maps](https://github.com/WICG/import-maps) is [starting to ship](https://chromestatus.com/feature/5315286962012160), which will let let browsers support bare module specifiers. In the meantime, bare import specifiers can easily be transformed as a build step. There are also some polyfills and module loaders that support import maps.
33
33
34
+
### Modern browser breakdown
35
+
36
+
All modern browsers update automatically and users are highly likely to have a recent version. The following table lists the minimum version of each major browser that natively supports ES2020 and web components, the key features on which Lit relies.
37
+
38
+
| Browser | Supports ES2020 & web components |
39
+
|:--------|:--------------------------------:|
40
+
| Chrome | >=80 |
41
+
| Safari | >=13 |
42
+
| Firefox | >=72 |
43
+
| Edge | >=80 |
44
+
34
45
## Requirements for legacy browsers {#building-for-legacy-browsers}
35
46
36
47
Supporting older browsers (specifically Internet Explorer 11, but also older versions of evergreen browsers), requires a number of extra steps:
@@ -39,6 +50,19 @@ Supporting older browsers (specifically Internet Explorer 11, but also older ver
39
50
* Transforming ES modules to another module system.
40
51
* Loading polyfills.
41
52
53
+
### Legacy browser breakdown
54
+
55
+
The following table lists supported browser versions that require transpiling Javascript and loading polyfills:
Rollup, webpack and other build tools have plugins to support transpiling modern JavaScript for older browsers. [Babel](https://babeljs.io/) is the most commonly used transpiler.
@@ -79,7 +103,7 @@ The IIFE format works fine if all of your code can be bundled into a single file
79
103
80
104
## Polyfills {#polyfills}
81
105
82
-
Using Lit on older browsers will require loading polyfills for standard JavaScript features like Promises and async/await, the Web Components polyfills, as well as a `polyfill-support` script provided in the Lit package for interfacing Lit with the Web Components polyfills.
106
+
Using Lit on older browsers will require loading polyfills for standard JavaScript features like Promises and async/await, the web components polyfills, as well as a `polyfill-support` script provided in the Lit package for interfacing Lit with the Web Components polyfills.
83
107
84
108
These are the recommended polyfills:
85
109
@@ -91,12 +115,71 @@ These are the recommended polyfills:
*[`@webcomponents/webcomponentsjs`](https://www.npmjs.com/package/@webcomponents/webcomponentsjs) - Polyfills for custom elements, shadow DOM, template, and some newer DOM APIs
94
-
*`lit/platform-support.js` - A file that ships in the `lit` package that must be loaded when using `webcomponentsjs`
118
+
*`lit/polyfill-support.js` - A file that ships in the `lit` package that must be loaded when using `webcomponentsjs`
119
+
120
+
Note that you may need other polyfills depending on the features your application uses.
121
+
122
+
### Loading polyfills
95
123
96
-
<divclass="alert alert-info">
124
+
The Javascript polyfills should be bundled separately from the application bundle, and loaded before the web components polyfills, since those polyfills rely on modern JS like `Promise`. Putting it all together, the page should load code as follows:
97
125
98
-
Note that the Javascript polyfills should be bundled separately from the application bundle, and loaded before the Web Components polyfills, since those polyfills rely on modern JS like `Promise`.
Note that you may need other polyfills depending on the features your application uses.
135
+
For detailed information about loading and configuring the web components polyfills, see the [webcomponentsjs documentation](https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs). The following is a summary of some of the key points.
136
+
137
+
#### Loading options
138
+
139
+
There are two main ways to load the web components polyfills:
140
+
141
+
-`webcomponents-bundle.js` includes all of the polyfills necessary to run on any of the supported browsers. Because all browsers receive all polyfills, this results in extra bytes being sent to browsers that support one or more feature.
142
+
-`webcomponents-loader.js` performs client-side feature-detection and loads just the required polyfills. This requires an extra round-trip to the server, but saves bandwidth for browsers that support one or more features.
143
+
144
+
#### Loading the ES5 adapter
145
+
146
+
It's best to serve a modern build to modern browsers to avoid sending the extra code needed for older browsers. However, it can be convenient to serve just a single set of files. If you do this, there is one extra required step. In order for ES5 transpiled code to work with native web components and specifically custom elements, a small adapter is needed. For a detailed explanation, see the [webcomponentsjs documentation](https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs#custom-elements-es5-adapterjs).
147
+
148
+
Load the `custom-elements-es5-adapter.js` after any Babel polyfills and before web components, like this:
By default, the individual polyfill for a given feature is disabled on browsers that natively support that feature.
161
+
For testing purposes, you can force the polyfills on for browsers that have native support.
162
+
163
+
While the web components polyfills strive to match the spec, there are some infidelities particularly around styling (see [ShadyCSS limitations](https://github.com/webcomponents/polyfills/tree/master/packages/shadycss#limitations)). We recommend ensuring you test with polyfills both on and off, either on the browsers that need them, or by forcing them on. You can force the polyfills on by adding a JavaScript snippet before you import the polyfills:
164
+
165
+
```html
166
+
<script>
167
+
// Force all polyfills on
168
+
if (window.customElements) window.customElements.forcePolyfill=true;
Copy file name to clipboardExpand all lines: packages/lit-dev-content/site/guide/tools/testing.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ The test environment you use must have support for using modern Javascript, incl
32
32
33
33
To test on older browsers, your test environment will need to load some polyfills, including the [web components polyfills](https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs) and Lit's `polyfill-support` module. See the [Browser Support](../browser-support) documentation for more details.
34
34
35
-
## Using Web Test Runner
35
+
## Using Web Test Runner { #web-test-runner }
36
36
37
37
We recommend using [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) since it is specifically designed to test modern web libraries like Lit using modern web features like custom elements and shadow DOM. See the [Getting Started](https://modern-web.dev/guides/test-runner/getting-started) documentation for Web Test Runner.
0 commit comments