---
title: "Discussion on \"Use JavaScript running web app in the background\" | Hashnode"
description: "Discussion on \"Use JavaScript running web app in the background\". 有時有需求在背景時仍然要同步資料，當 User 切回頁面時，仍然可以看到最及時的資料。或是發送通知給 User、持續上傳檔案等需求，都需要使用到 javscript 在 Web APP 背景執行的能力。\n使瀏覽在背景下繼續執行的方式有許多種，不過以支援度來說最常使用的 Service worker ，並透過 Page Visibility API 確認瀏覽器是否是在背景模式。\nService worker 根據不同的裝置(Mobile, Desktop)與瀏覽器(Chrome, Firefox,..."
url: "https://hashnode.com/posts/use-javascript-running-web-app-in-the-background/646986be7799fe7e829d60e5"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Use JavaScript running web app in the background](https://tp6gw94.hashnode.dev/use-javascript-running-web-app-in-the-background?utm_source=hashnode&utm_medium=feed)

有時有需求在背景時仍然要同步資料，當 User 切回頁面時，仍然可以看到最及時的資料。或是發送通知給 User、持續上傳檔案等需求，都需要使用到 javscript 在 Web APP 背景執行的能力。 使瀏覽在背景下繼續執行的方式有許多種，不過以支援度來說最常使用的 Service worker ，並透過 Page Visibility API 確認瀏覽器是否是在背景模式。 Service worker 根據不同的裝置(Mobile, Desktop)與瀏覽器(Chrome, Firefox,...

May 21, 2023 · 6 min read · tp6gw94.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#web-push](https://hashnode.com/tag/web-push)
-   [#background](https://hashnode.com/tag/background)

## Written by

[Sheng Tai Chen](https://hashnode.com/@tp6gw94)

@tp6gw94 · Kaohsiung, TW

  
[View profile](https://hashnode.com/@tp6gw94)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
