disable.js 995 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. Copyright 2018 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import { logger } from 'workbox-core/_private/logger.js';
  8. import { isSupported } from './isSupported.js';
  9. import './_version.js';
  10. /**
  11. * If the browser supports Navigation Preload, then this will disable it.
  12. *
  13. * @memberof module:workbox-navigation-preload
  14. */
  15. function disable() {
  16. if (isSupported()) {
  17. self.addEventListener('activate', (event) => {
  18. event.waitUntil(self.registration.navigationPreload.disable().then(() => {
  19. if (process.env.NODE_ENV !== 'production') {
  20. logger.log(`Navigation preload is disabled.`);
  21. }
  22. }));
  23. });
  24. }
  25. else {
  26. if (process.env.NODE_ENV !== 'production') {
  27. logger.log(`Navigation preload is not supported in this browser.`);
  28. }
  29. }
  30. }
  31. export { disable };