|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | Copyright 2018 Google LLC
|
|---|
| 3 |
|
|---|
| 4 | Use of this source code is governed by an MIT-style
|
|---|
| 5 | license that can be found in the LICENSE file or at
|
|---|
| 6 | https://opensource.org/licenses/MIT.
|
|---|
| 7 | */
|
|---|
| 8 | import { logger } from 'workbox-core/_private/logger.js';
|
|---|
| 9 | import { isSupported } from './isSupported.js';
|
|---|
| 10 | import './_version.js';
|
|---|
| 11 | /**
|
|---|
| 12 | * If the browser supports Navigation Preload, then this will enable it.
|
|---|
| 13 | *
|
|---|
| 14 | * @param {string} [headerValue] Optionally, allows developers to
|
|---|
| 15 | * [override](https://developers.google.com/web/updates/2017/02/navigation-preload#changing_the_header)
|
|---|
| 16 | * the value of the `Service-Worker-Navigation-Preload` header which will be
|
|---|
| 17 | * sent to the server when making the navigation request.
|
|---|
| 18 | *
|
|---|
| 19 | * @memberof workbox-navigation-preload
|
|---|
| 20 | */
|
|---|
| 21 | function enable(headerValue) {
|
|---|
| 22 | if (isSupported()) {
|
|---|
| 23 | self.addEventListener('activate', (event) => {
|
|---|
| 24 | event.waitUntil(self.registration.navigationPreload.enable().then(() => {
|
|---|
| 25 | // Defaults to Service-Worker-Navigation-Preload: true if not set.
|
|---|
| 26 | if (headerValue) {
|
|---|
| 27 | void self.registration.navigationPreload.setHeaderValue(headerValue);
|
|---|
| 28 | }
|
|---|
| 29 | if (process.env.NODE_ENV !== 'production') {
|
|---|
| 30 | logger.log(`Navigation preload is enabled.`);
|
|---|
| 31 | }
|
|---|
| 32 | }));
|
|---|
| 33 | });
|
|---|
| 34 | }
|
|---|
| 35 | else {
|
|---|
| 36 | if (process.env.NODE_ENV !== 'production') {
|
|---|
| 37 | logger.log(`Navigation preload is not supported in this browser.`);
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 | export { enable };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.