diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/glossary/main_thread | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/glossary/main_thread')
-rw-r--r-- | files/zh-cn/glossary/main_thread/index.html | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/files/zh-cn/glossary/main_thread/index.html b/files/zh-cn/glossary/main_thread/index.html new file mode 100644 index 0000000000..ceb985bb00 --- /dev/null +++ b/files/zh-cn/glossary/main_thread/index.html @@ -0,0 +1,25 @@ +--- +title: 主线程 +slug: Glossary/Main_thread +translation_of: Glossary/Main_thread +--- +<p><strong>主线程</strong>用于浏览器处理用户事件和页面绘制等。默认情况下,浏览器在一个线程中运行一个页面中的所有 JavaScript 脚本,以及呈现布局,回流,和垃圾回收。这意味着一个长时间运行的 JavaScript 会阻塞线程,导致页面无法响应,造成不佳的用户体验。</p> + +<p>除非故意使用 <a href="/en-US/docs/Web/API/Web_Workers_API/Using_web_workers">web worker</a>,比如 <a href="/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers">service worker</a>,不然 JavaScript 只在线程中运行,所以脚本的运行时,很容易导致事件处理流程或绘制的延迟。主线程中运行的工作越少,就有越多的余地来处理用户事件,页面绘制和对用户保持响应。 </p> + +<section class="Quick_links" id="Quick_Links"> +<ol> + <li>另可参考 + <ol> + <li><a href="/en-US/docs/Learn/JavaScript/Asynchronous">异步 JavaScript</a></li> + <li><a href="/en-US/docs/Web/API/Web_Workers_API">Web worker API</a></li> + <li><a href="/en-US/docs/Web/API/Service_Worker_API">Service worker API</a></li> + </ol> + </li> + <li><a href="/en-US/docs/Glossary">词汇表</a> + <ol> + <li>{{Glossary("Thread")}}</li> + </ol> + </li> +</ol> +</section> |