From Documentation

Jump to: navigation, search


<javascript package="pkg_name" [merge="false|true"]/>
<javascript package="pkg_name" merge="a_package_to_merge_to"/>
<javascript package="pkg_name" [ondemand="false|true"/>
<javascript src="a_uri"/>

It specifies the JavaScript package or file that has to be loaded to the client. It could also specify the content (the JavaScript code snippet) directly. Notice that, if specified, it is always loaded, no matter if it is required or not.


<javascript package=""/>




It specifies the package to load.



It specifies the URI of the JavaScript file to load. The URI could contain ~./ (such as "~./foo/whatever.js") to indicate a JavaScript file should be loaded from the classpath.


[Optional][Default: false]

It is used with the package attribute to specify whether the package should be loaded as part of the zk package. If not specified, each package will be loaded separatedly. This speeds up the loading if we merge several packages into one.

Since ZK 6, it is allowed to specify the target package in the merge attribute. For example,

<javascript package="foo.lang" merge="zul.lang"/>

In fact, merge="true" is the same as merge="zk", i.e., merged to the zk package. Notice that the target package must be a preloaded package. In other words, it must be specified in another javascript element (without the ondemand attribute). In most cases, you shall use zk for packages that can be cached at the client, and use zul.lang for packages that shall not be cached, such as your own locale-dependent messages.

For more information, please refer to the Performance Tips section.


[Optional][Default: false]

It is used to 'cancel' the package specified in another javascript element. By default, JavaScript packages are loaded on-demand (i.e., when it is required). By specify <javascript;> in a language definition/addon, we could force some packages to load at the beginning. But if you change your mind, you could either remove the javascript element, or specify another javascript element with ondemand="true".

Version History

Last Update : 2011/9/29

Version Date Content
6.0.0 September 2011 The merge attribute could be specified with the package's name to merge to, such as zul.lang.

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.