Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

disable.mjs 1.3 KiB

3 anos atrás
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. Copyright 2017 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. import {logger} from 'workbox-core/_private/logger.mjs';
  14. import {isSupported} from './utils/isSupported.mjs';
  15. import './_version.mjs';
  16. /**
  17. * If the browser supports Navigation Preload, then this will disable it.
  18. *
  19. * @memberof workbox.navigationPreload
  20. */
  21. function disable() {
  22. if (isSupported()) {
  23. self.addEventListener('activate', (event) => {
  24. event.waitUntil(
  25. self.registration.navigationPreload.disable().then(() => {
  26. if (process.env.NODE_ENV !== 'production') {
  27. logger.log(`Navigation preload is disabled.`);
  28. }
  29. })
  30. );
  31. });
  32. } else {
  33. if (process.env.NODE_ENV !== 'production') {
  34. logger.log(`Navigation preload is not supported in this browser.`);
  35. }
  36. }
  37. }
  38. export {disable};