减少小程序加载时间

减少小程序加载时间

本文介绍了减少小程序加载时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 html 文件,其中包含一个 jar 文件作为小程序.当我打开 html 文件时,加载小程序的时间太多了.

I have an html file which has a jar file included in it as an applet. When ever i am opening the html file its getting too much time to load the applet.

有什么办法可以减少这个加载时间??

Is there any way by which i can reduce this loading time??

推荐答案

这里有三个主要因素在起作用.

There's at three major factors in play here.

1) Java 启动时间.冷启动过去是 5-10 秒,但是随着 Java 快速入门,它是 Java 1.6 更新 10 的一部分.默认情况下,Windoes XP 和 2000(Vista 提供自己的预加载机制)启用此功能,但也许您已禁用此功能(启用信息).

1) Java startup time. Cold start used to be 5-10 seconds, however this has changed with the Java quickstarter which was part of the Java 1.6 update 10. This is on by default for Windoes XP and 2000 (Vista offers its own pre-loading mechanisms), but maybe you have this disabled (enable information).

2) 小程序的下载时间.在本地进行测试,如果启动时间明显不同,请考虑使用更好的压缩技术.Proguard 将混淆代码并通过 高达 90%.90Kb 应该不会很慢,但这可能取决于您的网络速度和主机.

2) The download time for your applet. Test it locally and if the startup time is significantly different consider using better compression techniques. Proguard will obfuscate code and reduce the code size by upto 90 percent. 90Kb shouldn't be slow, but this could depend on your network speed and host.

3) 用于初始化小程序的代码.您可以临时更改您的 init 方法以仅显示一个 hello world 按钮来确定这是否有问题.如果您对性能不满意,您可能需要分析您的代码.

3) The code you're using to initialize the applet. You could temporarily change your init method to just show a hello world button to identify if that is a problem. If you're not happy with the performance you may need to profile your code.

Applet 启动时间应该在 1 秒左右(不包括下载时间).检查您是否有相当新的 Java 并尝试一个简单的 Hello World 小程序.

Applet startup time should be around a second (excluding download time). Check you have a fairly recent Java and try a simple Hello World applet.

这篇关于减少小程序加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 15:32