Adding Javascript resources in theme
-
28-10-2019 - |
Question
The css files are added on the Xpage correctly, but when I add JS resource it's not added, and I have no idea why? This is what i write:
<resource>
<content-type>text/javascript</content-type>
<href>addThis.js</href>
</resource>
Tnx in advance
Solution
Your content-type is wrong. To add a clientside Javascript library through a theme you need to use application/x-javascript:
<resource>
<content-type>application/x-javascript</content-type>
<href>addThis.js</href>
</resource>
OTHER TIPS
If you are talking about CLIENT side javascript you should use the following markup:
<theme extends="oneuiv2.1">
<script target="xsp" src="/yourscript.js" clientSide="true" type="text/javascript"/>
</theme>
For serverside script use
<theme extends="oneuiv2.1">
<script target="xsp" src="*/yourscript.jss" clientSide="false" type="text/javascript"/>
</theme>
According to Mastering Xpages you should use content-type "text/x-javascript". Have you tried that?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow