HTML导入不会重复数据删除 [英] HTML import not deduping

查看:135
本文介绍了HTML导入不会重复数据删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这个的第一个事实部分HTML导入文章指出,html导入比请求(并执行 - 如果javascript)资源多次。

So the first fact section in this HTML import article states that html imports know better than to request (and execute - if javascript) resources multiple times.

这可以在HTML导入的框架内工作,但不适用于其他类型的导入(如在javascript中)。在devtools的这个网络视图中,您可以从javascript( d3.js )首先加载 Polymer.html 再次从HTML导入( my-app.html ),我不期待。

This works within the framework of HTML imports but doesn't work for other type of imports (as in javascript). In this network view of the devtools you can see Polymer.html being loaded first from javascript (d3.js) then again from HTML imports (my-app.html) which I wasn't expecting.

有没有一种方法来明确指出HTML导入资源已经被加载(如在这种情况下从javascript)?

Is there a way to explicitly tell HTML imports that a resource has already been loaded (as in from javascript in this case)?

推荐答案

如果我正确理解,你是脚本文件加载多次,因为它们被调用多个元素。请纠正我,如果这不正确。

If I understand this correctly, you are having script file load multiple times because they are called in multiple elements. Please correct me if this is not right.

我确实看到HTML文件是被解析了两次,但它内部的脚本实际上是从缓存(在第二个参考)。如果您不希望再次解析HTML文件,则需要在服务器或服务工作者级别为HTML设置缓存。

I do see that the HTML file is what is being parsed twice but the script inside it is actually pulled from cache (on the second reference). If you don't want the HTML file to be parsed again, you'll need to setup caching for the HTML at the server or Service Worker level.

这篇关于HTML导入不会重复数据删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆