This document discusses ways in which the load time of EditLive! for Java can be optimized. There are several ways in which the load time of EditLive! for Java may be reduced. These include the preloading of the Java Plug-in, configuring EditLive! for Java via XML text embedded in the relevant Web page, setting the document styles via the EditLive! for Java styles property and deploying the Java Runtime Environment in the manner best suited to your environment.
In order to run the EditLive! for Java applet a browser must first load the Java Plug-in. The loading of the Java Plug-in occurs the first time a browser session seeks to use a Java applet and the loading of the plug-in can take a noticeable amount of time. EditLive! for Java includes functionality which allows for the preloading of the Java Plug-in for a browser session. This functionality can be added to any page within the relevant Web application to decrease the load time of EditLive! for Java when it is eventually used. This functionality may be of most use when implemented on the user login page of a Web application as it will decrease the load time for future uses of EditLive! for Java within the Web application during the relevant session.
An example of the preloading functionality, implemented in JavaScript, can be seen below. For more information please refer to the setPreload property in the JavaScript API or the preload property within your EditLive! for Java SDK.
The following code would preload the JVM and EditLive! for Java classes and then alert the user that EditLive! for Java has finished loading by using the preloadReturn callback function to create a JavaScript alert dialog.
<script language="javascript">
...
var editlivejava1;
editlivejava1 = new EditLiveJava("ELJApplet1","1","1");
editlive1.setDownloadDirectory("redistributables/editlivejava");
editlive1.setXMLURL("redistributables/editlivejava/sample_eljconfig.xml");
editlive1.setBody(" ");
editlive1.setPreload("preloadReturn");
editlive1.show();
function preloadReturn(){
alert("EditLive! for Java has completed
preloading.");
}
...
</script>
When using an XML configuration file to customize the EditLive! for Java interface EditLive! for Java must make a HTTP request to the server to retrieve the relevant XML file. However, if the EditLive! for Java configuration is set via an XML document which is embedded directly in the relevant page EditLive! for Java no longer has to make an extra HTTP request to the Web server and load time is decreased.
Embedding an XML configuration document within the relevant Web page can be achieved by simply placing a URL encoded version of the XML configuration file onto the page. However, it may be advisable to use the file reading capabilities of your server side scripting language to read the relevant file directly from the Web server's file system into a temporary scripting variable on the relevant page and then load it into EditLive! for Java. This is achieved via the setXML property in the JavaScript SDK or via the ConfigurationText of all other SDKs.
The following JavaScript code passes in an XML document which will be used to customize EditLive! for Java. The code uses the default JavaScript escape function to encode the document, however, where possible, a server-side URL encoding method should be used to escape the XML text.
Note:
var editlivejava1;
editlivejava1 = new EditLiveJava("ELJApplet1","700","400");
editlivejava1.setXML(escape("<?xml version="1.0" encoding="ISO-8859-1"?>
<editLiveForJava><document>...));
Setting the document styles via an external style sheet causes EditLive! for Java to make a HTTP request to the relevant Web server. In order to avoid this the document styles can be set via the relevant styles property. The example below uses the setStyles property from the JavaScript SDK.
The following code would set the initial style rules of the document within EditLive! for Java to be equal to "body{ font-family: arial; background-color: white;}h1{ font-family: helvetica, arial, sans-serif; font-size: 16pt; font-style: normal; font-weight: bold;}p, td, th{ font-size: 12pt;}". This style information will be used to render the contents of EditLive! for Java and will only be visible in the HTML View.
Note: The string passed to the setStyles property must be URL encoded or encoded using the JavaScript escape function. The example below uses the JavaScript escape function, however, where possible, a server side URL encoding method should be used.
var editlivejava1;
editlivejava1 = new EditLiveJava("ELJApplet1","700","400");
editlivejava1.setBody(escape("<p>Initial contents of Ephox EditLive! for
Java</p>"));
editlive1.setStyles(escape('body{ font-family: arial; background-color: white;}h1{ font-family: helvetica, arial, sans-serif; font-size: 16pt; font-style: normal; font-weight: bold;}p, td, th{ font-size: 12pt;}'));
In order to use EditLive! for Java users must have the Java Runtime Environment (JRE) installed on their machine. If a user does not have the required version of the Java Runtime Environment installed on their machine it will be deployed automatically. In cases where the users of EditLive for Java are connected to a local intranet it may be fastest to deploy the JRE from the local server. A copy of the JRE is provided with EditLive! for Java for this purpose. To use this installer simply set the local deployment property of EditLive! for Java to true. The following example demonstrates how to achieve this with the setLocalDeployment property of the JavaScript SDK.
The following code creates an instance of EditLive! for Java and sets it to use the local copy of the JRE files from the server.
var editlivejava1;
editlivejava1 = new EditLiveJava("ELJApplet1","700","400");
editlivejava1.setLocalDeployment(true);
The load time of EditLive! for Java can be optimized through the use of several developer features. Through the use of these features initial load times can be reduced. Developers can optimize the load time of EditLive! for Java by preloading the Java Plug-in, setting the document styles and XML in the relevant Web page and downloading the JRE from the local servers if EditLive! for Java is being accessed via an intranet.
Copyright © 2001-2004 Ephox Corporation. All Rights Reserved.