Question

Can I conditionally include javascript file and css files.

<xbl:script src="/apps/xforms-sandbox/samples/myfile.js" />

Can this be done conditionally?

Was it helpful?

Solution

At this point, in Orbeon Forms, you can't conditionally include scripts with <xbl:script> or CSS with <xbl:style>. To include dynamic resources, use HTML the elements <xhtml:script> and <xhtml:style> you generate with XSTL, inside the <xbl:template> of your XBL component. If you can use static resource, you should:

  1. To avoid duplication — If you have multiple instances of your component when the page is loaded, then the same JavaScript or CSS will end up being included multiple times in the page. You might say: well, but this is the case anyway when using <xbl:script> and <xbl:style>. Yes, but this is a bug, which hopefully we'll get a chance to fix soon.
  2. To benefit from automatic minimization and combination — We are planning to automatically combine and minimize the resources references in XBL components, just like we do for resources used by the core XForms engine itself. You will be able to benefit from this feature when it lands in the codebase if you use <xbl:script> and <xbl:style>.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top