开发者

Conditionally include javascript file in xbl

开发者 https://www.devze.com 2023-01-25 11:50 出处:网络
Can I conditionally include javascript file and css files. <xbl:script src=\"/apps/xforms-sandbox/samples/myfile.js\" />

Can I conditionally include javascript file and css files.

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

Can this be done conditi开发者_JS百科onally?


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>.
0

精彩评论

暂无评论...
验证码 换一张
取 消