gkidd
gkidd

Reputation: 199

Adding Javascript resources in theme

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

Upvotes: 1

Views: 1694

Answers (3)

Mark Leusink
Mark Leusink

Reputation: 3757

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>

Upvotes: 8

Thimo Jansen
Thimo Jansen

Reputation: 485

According to Mastering Xpages you should use content-type "text/x-javascript". Have you tried that?

Upvotes: 1

jjtbsomhorst
jjtbsomhorst

Reputation: 1667

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>

Upvotes: 3

Related Questions