Javascript Optimization

The page loading time must be as small as possible, and this time depends on the size of JavaScript source code the browser loads and how the functions are called.

JavaScriptCollector Tag

This tag allows to gather all the <SCRIPT> HTML tags in only one. Some browser (i.e: Internet Explorer) could have a loss of performance when they have too many <SCRIPT> tag on the same page. The best way yo use it is to use the <vh:javaScriptCollector> tag like this :

<?xml version="1.0" encoding="UTF-8"?>

<jsp:root

        

      version="2.0"

      xmlns="http://www.w3.org/1999/xhtml"

      xmlns:jsp="http://java.sun.com/JSP/Page"

      xmlns:f="http://java.sun.com/jsf/core"

      xmlns:h="http://java.sun.com/jsf/html"

      xmlns:v="http://rcfaces.org/core"

      xmlns:vh="http://rcfaces.org/html"

      xmlns:layout="http://jakarta.apache.org/struts/tags-tiles">

 

      <jsp:directive.page

            contentType="text/html"

            pageEncoding="UTF-8" />

 

      <layout:importAttribute scope="request"/>

 

      <f:view>

            <jsp:output

                omit-xml-declaration="true"

                doctype-root-element="html"

                doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"

                doctype-system="http://www.w3.org/TR/html4/loose.dtd" />

         

            <html lang="fr">

                <jsp:directive.include file="_header.jspf" />                      

                    <vh:javaScriptCollector>


                    <body>

                        <h:form id="ecranGlobal">

                                  

                           <jsp:directive.include file="_body.jspf" />

     

                          <!-- Menu Horizontal -->

                                  

                           <div class="zoning_menuHorizontal">

                              <f:subview id="menuHorizontal">

                                <jsp:include page="${menuHorizontal}flush="false" />

                              </f:subview>

                           </div>

                   [...]                      

                         </h:form>

                     </body>

                    </vh:javaScriptCollector>

            </html>

      </f:view>

</jsp:root>

Compiled Versions of the RCFaces runtime

There are two special versions of  rc-faces-html.jar with different compilation parameters to improve size and loading time of the JavaScript runtime : 

Version Size Loading Time
HTML 1 1 Free
HTMLC 0.22 0.6 Free
HTMLC3 0.26 0.33 Premium

These jar file will be put in the WEB-INF/lib folder of your application. They replace the rc-faces-html.jar file. We advise not to use them at development time as they make the debugging of the cleint-side scripts much harder. Use them at application-deployment time.