【问题标题】:What's the difference between importScripts and ES6 modules/import?importScripts 和 ES6 模块/导入有什么区别?
【发布时间】:2017-07-04 09:01:59
【问题描述】:

我目前与 Service Worker 一起实现了一个前端。 由于我的 Service Worker 需要多个代码片段,因此我选择使用标准中的 importScripts 函数。

我真的不明白为什么 importScripts 被添加到这个标准中,因为大约 3 年前modules 成为 ES6 标准的一部分(尽管在大多数浏览器中仍然缺少,如果不使用标志的话)。

有人可以详细说明一下吗? 我认为它与错误处理等有关......

【问题讨论】:

    标签: service-worker progressive-web-apps es6-modules


    【解决方案1】:

    经过一些研究,底线是 importScripts 的规范比 ES6 模块的规范更早。从长远来看,服务工作者中的 ES6 模块 likely will be supported。到目前为止它是not supported in Chrome Canary yet,尽管从 60 版开始就有对前端的 ES6 模块支持。

    【讨论】:

      猜你喜欢
      • 2019-09-21
      • 1970-01-01
      • 1970-01-01
      • 2010-10-02
      • 1970-01-01
      • 2016-05-15
      • 2019-08-23
      • 2011-04-10
      • 2013-01-11
      相关资源
      最近更新 更多