简体   繁体   English

为什么在CrossRider中加载背景需要花费大量时间?

[英]Why does it take so much time for the background to load in CrossRider?

We are using CrossRider to develop an extension for Internet Explorer. 我们正在使用CrossRider开发Internet Explorer扩展。 I tested our extension in staging mode, and there is an alert in the background and in extension.js in the function appAPI.ready : 我在登台模式下测试了我们的扩展,在后台以及在appAPI.ready函数的extension.js中有一个警报:

extension.js : extension.js

appAPI.ready(function($) {
    alert("appAPI.platform = " + appAPI.platform);
});

background.js : background.js

appAPI.ready(function($) {
    alert("appAPI.platform = " + appAPI.platform);
});

The alert in extension.js happens immediately after I install the extension, but the alert in background.js happens only after 26 seconds. 我安装扩展程序后,extension.js中的警报立即发生,但是background.js中的警报仅在26秒后发生。 Why does it take so much time? 为什么要花这么长时间? Our Extension ID is 43889. I also tried with a simple extension that doesn't do almost anything (Extension ID is 67708), and there both the alerts happen immediately. 我们的扩展ID是43889。我还尝试了一个几乎不能执行任何操作的简单扩展(扩展ID为67708),并且两个警报都立即发生。 Is there a way to make the background in our extension load faster? 有没有办法使我们的扩展程序中的后台加载速度更快?

I'm using Internet Explorer 11 but this extension should work on all versions of Internet Explorer. 我使用的是Internet Explorer 11,但此扩展程序应可用于所有版本的Internet Explorer。

It would be nice if every browser provided a background scope, but unfortunately IE does not. 如果每个浏览器都提供背景范围,那将是很好的选择,但是不幸的是IE没有。 However, we make every effort to make the code behavior as similar as possible between browsers, but we can't redefine IE's architecture. 但是,我们竭尽全力使浏览器之间的代码行为尽可能相似,但是我们无法重新定义IE的体系结构。 Hence, for IE we implemented our own background scope and part of its initialization requires the loading of resource files. 因此,对于IE,我们实现了自己的后台作用域,并且其部分初始化要求加载资源文件。

Usually this is not a problem as most extension are lightweight and have few resources. 通常这不是问题,因为大多数扩展都是轻量级的,并且资源很少。 However, in your case, since you have a lot of resource files in your extension, it's delaying the initial load of the background scope, but once it's loaded the alerts show in a timely manner. 但是,在您的情况下,由于扩展中有很多资源文件,因此这会延迟后台范围的初始加载,但是一旦加载,警报就会及时显示。 That's why in your test extension that has no resources, the background alert is displayed immediately. 因此,在没有资源的测试扩展中,会立即显示背景警报。

[ Disclosure : I am a Crossrider employee] [ 披露 :我是Crossrider员工]

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

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