Reputation: 159
I placed my files as
where I wants to cache the index.js and mycss.css file which is not working. And due to some constraint, I can't put the service-worker.js in parallel to index.html page
Upvotes: 2
Views: 746
Reputation: 10614
Absolutely yes. Moreover, it is considered to be a standard practice to place similar/related files in their respective folder.
So, in your index.html
you could do something like this:
<body>
<script src="/files/mycss.css"></script>
<script src="/files/index.js"></script>
<script src="/files/service-worker.js"></script>
</body>
Upvotes: 2
Reputation: 355
Another approach of solving the problem is to set the Service-Worker-Allowed HTTP
response header if the scope of service-worker.js
is different from the scope of files it wants to work with. This idea helps in applications where URL rewriting is done or the context path for files is not similar to the actual directory structure.
Upvotes: 2
Reputation: 25
Yes you can put your files in different folders. When you want to "connect" your css to the html the path is:
src="files/mycss.css"
Hope this will help you.
Upvotes: 1