Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
External CSS isn't working from another sources in PWA

I am creating a PWA. At offline.html I want to add External CSS style instead of Internal CSS. I do link with it but although it shows status code of 200 at offline mode but doesn't work.

  • serviceWorker.js
const CACHE_NAME = 'pwa-version-1';
const urlsToCache = ['index.html', 'offline.html', 'style.offline.css', '../src/style/style.offline.css'];
const self = this;

// Installation service worker
self.addEventListener('install', (e) => {
    e.waitUntil(
        caches.open(CACHE_NAME)
        .then(cache => {
            console.log('Cache Opened')
            return cache.addAll(urlsToCache)
        })
        .catch()
    )
})

// Listen for request
self.addEventListener('fetch', (e) => {
    e.respondWith(
        caches.match(e.request)
        .then(() => {
            return fetch(e.request)
                .catch(() => {
                    return caches.match('offline.html')
                })
        })
        .catch()
    )
})

Note: If I remove 'style.offline.css', '../src/style/style.offline.css' then it return fetch failed.

  • offline.html
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../src/style/offline.css">
    <title>Weather App</title>
</head>

<body>
    <div class="city">
        <h2 class="city-name">
            <span>Please go online to check the current weather.</span>
        </h2>
    </div>
</body>

</html>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda