Wednesday, February 15, 2012

An improvement to inline JavaScript in actions

We just implemented a performance enhancement when using JavaScript from XForms, in particular from XBL components.

In Orbeon Forms, you typically call client-side JavaScript from actions with the <xxf:script> extension action or with <xf:action type="javascript"> (which is now the preferred way). For example, the Currency XBL component has a call like this:
Until now if  you used more than one instance of the currency component in your page, the inline scripts would be duplicated multiple times on the client.

Now, with this enhancement, each script body is associated a SHA1 hash based on its content, and a given script body is sent to the browser only once. This means less duplication of code.

Here is the documentation on <script> and <action> actions for scripting. And if you are interested in the implementation, here is the git commit, in particular PartEventHandlerAnalysis.scala.

No comments:

Post a Comment