简体   繁体   English

外部SVG中的样式表 - 是从缓存加载还是两次加载?

[英]Stylesheets in external SVG - are they loaded from cache or twice?

I have the following code to export an external SVG image (I can't use it inline for a number of reasons): 我有以下代码导出外部SVG图像(由于多种原因我不能使用它内联):

<head>
  <link rel="stylesheet" href="theme.css">
</head>

...

<object data="image.svg" type="image/svg+xml"></object>

The image itself: 图像本身:

<?xml-stylesheet href="theme.css" type="text/css"?>
<svg viewBox="0 0 100 100">...</svg>

So for the image I am loading the same theme.css I am loading for the page to use some classes from it. 所以对于图像我加载相同的theme.css我正在加载页面以使用它的一些类。 It works fine, however I wonder if the page loading speed is affected by that? 它工作正常,但我想知道页面加载速度是否受此影响? I checked the console and it looks like the second theme.css is loaded 10x times faster. 我检查了控制台,看起来第二个theme.css的加载速度提高了10倍。 Anybody can clarify how it works? 任何人都可以澄清它是如何工作的?

If you use your browsers developer tools by pressing F12, view the Network tab, and then reload the page you can see whether a resource was loaded from memory cache or disk cache. 如果按F12使用浏览器开发人员工具,请查看“网络”选项卡,然后重新加载页面,可以查看资源是从内存缓存还是磁盘缓存加载的。

You can also test doing a refresh by using Shift+F5 for a refresh without cache to see if the speeds slow down again. 您还可以使用Shift + F5进行刷新测试,无需缓存即可查看速度是否再次降低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM