This document discusses ways in which the load time of EditLive! for XML can be optimized. There are several ways in which the load time of EditLive! for XML may be reduced. These include preloading the Java Plug-in, configuring the instance of EditLive! for XML via text embedded in the relevant Web page instead of using URLs and deploying the Java Runtime Environment (JRE) in the manner best suited to your environment.
In order to run the EditLive! for XML 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 XML 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 XML 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 XML 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 Preload property in the EditLive! for XML SDK.
The following code would preload the JVM and EditLive! for XML classes and then alert the user that EditLive! for XML has finished loading by using the preloadReturn callback function to create a JavaScript alert dialog.
<script language="javascript">
...
var editlive1;
editlive1 = new EditLiveXML("ELApplet1","1","1");
editlive1.setDownloadDirectory("redistributables/editlivexml");
editlive1.setConfigurationFile("editlivexml/sample_elconfig.xml");
editlive1.setBody(" "); editlive1.setPreload("preloadReturn");
editlive1.show();
function preloadReturn(){
alert("Preloading of the JRE and applet is complete.");
}
...
</script>When using an XML configuration file to customize the EditLive! for XML interface EditLive! for XML must make a HTTP request to the server to retrieve the relevant XML file. However, if the EditLive! for XML configuration is set via an XML document which is embedded directly in the relevant page EditLive! for XML 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 is 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 XML. This is achieved via the ConfigurationText property.
The following JavaScript code passes in an XML document which will be used to customize EditLive! for XML. 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.
The XML document seen here is not complete. The XML text passed in must comply with the EditLive! for XML Configuration DTD.
The string passed to the setConfigurationText property must be URL encoded or encoded using the JavaScript escape function. The example below uses the JavaScript escape function but it is recommended that a server-side URL encoding method be used.
var editlive1;
editlive1 = new EditLiveXML("ELApplet1","700","400");
editlive1.setConfigurationText(
escape('<?xml version="1.0" encoding="UTF-8"?> <editLive>...');The data model and views for EditLive! for XML and the Visual Designer can also be provided by text embedded in the Web page. Views can be added to EditLive! for XML through the addViewAsText method which data models may be added via the addXSDAsText. Loading views and data models via this method will decrease load times by ensuring that EditLive! for XML is not required to make a request to the server. Views and data models loaded via this method must be provided as a complete, URL encoded, XML style sheet (XSL) or XML Schema Documents (XSDs) respectively. It is advised that the file reading and URL encoding capabilities of a server-side scripting language be used to provide the XSL to the relevant Web page.
The following JavaScript code passes in an XSL and an XSD which will be used to by EditLive! for XML. The code uses the default JavaScript escape function to encode the documents, however, where possible, a server-side URL encoding method should be used to escape the document text.
The XSL and XSD documents seen here are not complete. The document text passed in must comply with the XSL and XSD standards.
The document text passed to the addViewAsText and addXSDAsText methods must be URL encoded or encoded using the JavaScript escape function. The example below uses the JavaScript escape function but it is recommended that a server-side URL encoding method be used.
var editlive1;
editlive1 = new EditLiveXML("ELApplet1","700","400");
editlive1.addViewAsText(
escape('<?xml version="1.0"?>...','First View'));
editlive1.addXSDAsText(
escape('<?xml version="1.0"?>...'));In order to use EditLive! for XML 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 XML for this purpose. To use this installer simply set the local deployment property of EditLive! for XML to true. The following example demonstrates how to achieve this with the LocalDeployment property of the JavaScript SDK.
The load time of EditLive! for XML 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 XML by preloading the Java Plug-in, setting various properties via text embedded in the relevant Web page and downloading the JRE from the local servers if EditLive! for XML is being accessed via an intranet.
Copyright 2001-2004 Ephox Corporation. All Rights Reserved.