IE11渲染/加载图标晚于其他浏览器

时间:2018-06-28 10:13:01

标签: javascript angular svg icons

我正在使用Angular 5应用程序,并在整个站点中使用SVG图标。在Chrome,Mozilla和Safari等常规浏览器中,图标可以正确加载,但在IE11中不能。

为此,我在pollyfill.ts文件中添加了 svgxuse https://github.com/Keyamoon/svgxuse

此更改后,所有图标现在都已加载到IE11浏览器中,但加载时间很晚。我的意思是,将所有内容加载到屏幕上大约需要1-2秒。

从用户角度来看这不是很好。有谁知道如何在IE浏览器中预加载/快速加载这些图标。

谢谢。

1 个答案:

答案 0 :(得分:0)

我认为您不能做太多..也许尝试服务工人(我不知道他们是否在IE11中工作)..使用Service worker可以加载和缓存图像和资产。 ..

类似:(在您的ngsw-config.js文件中)

{
  "index": "/index.html",
  "assetGroups": [{
    "name": "app",
    "installMode": "prefetch",
    "resources": {
      "files": [
        "/favicon.ico",
        "/index.html"
      ],
      "versionedFiles": [
        "/*.bundle.css",
        "/*.bundle.js",
        "/*.chunk.js"
      ]
    }
  }, {
    "name": "assets",
    "installMode": "lazy",
    "updateMode": "prefetch",
    "resources": {
      "files": [
        "/assets/**"
      ]
    }
  }]
}

然后在angular.cli.json文件集中设置:

"serviceWorker": true

希望对您有帮助!

相关问题