ServiceWorker 中的 RequireJS

标签 requirejs offline amd web-worker service-worker

ServiceWorker 范围内使用 RequireJS 导入外部库的正确方法是什么?

在 WebWorkers 范围内我们可以使用 importScripts() RequireJS in web worker . 如何在 我们可以离线 的 ServiceWorker 范围内解决?

我认为 ImportScript() 会失败,然后需要将库搜索到 Serviceworker 缓存中,有什么建议吗?

非常感谢。

PD:我尝试创建标签“service-worker”,但我没有足够的声誉;((我改用 web-worker)。

最佳答案

我在 ServiceWorker / explainer.md 找到了答案

The scripts that have been imported the first time the worker is run will be cached along side it by the browser. The upside is that imported scripts will be downloaded and cached alongside the main ServiceWorker script.

关于ServiceWorker 中的 RequireJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25831705/

相关文章:

javascript - requirejs 看不到 jquery

javascript - ItemView 不会呈现

javascript - 使用 RequireJS 加载 Marionette (v3) 的正确方法是什么?

maven - 在没有互联网接入的情况下使用 Maven 或 Gradle 的最佳实践

php - Android Web 应用程序 - 带有本地数据库的 php

javascript - 我如何从我的 Service Worker 访问我的 Dexie 数据库?

javascript - 使用 AMD 和 Moodle

javascript - 无法解析模块 'react/lib/merge'

opencl - Nvidia GPU 是否支持类似管道的结构?

javascript - Require.js 要求/定义缺少参数的后果