browser

进程是操作系统分配资源的基本单位,拥有独立的内存空间,

而线程是进程中的执行单元,多个线程共享同一进程的资源。

Process

https://developer.chrome.com/blog/inside-browser-part1

Thread


The
JavaScript engine corresponds to the main thread in the renderer process.

+--------------------------+           +-------------------+
|     Renderer Process      | <-------> |  GPU Process      | <--- Handles graphics rendering
+--------------------------+           +-------------------+
|   +--------------------+  |
|   |  Main Thread       |  | <--- Executes JavaScript and handles the event loop
|   +--------------------+  |
|   |  Render Thread     |  | <--- Parses HTML/CSS, builds DOM/CSSOM
|   +--------------------+  |
|   |  Layout Thread     |  | <--- Calculates layout
|   +--------------------+  |
|   |  Paint Thread      |  | <--- Renders content to the screen
|   +--------------------+  |
+--------------------------+

插件:

特性浏览器插件Webpack 插件iframe 插件
主要用途扩展浏览器功能扩展 Webpack 构建将外部应用嵌入网页
运行环境浏览器(background/content script)Node.js(Webpack 构建时)浏览器(沙盒环境)
代码注入可能(content script)否(受限于沙盒)
典型应用广告拦截、翻译、ChatGPT 插件代码优化、热更新在线客服、支付插件
与其他技术的关联可以注入 iframe可以打包插件代码需要与 content script 交互