How to recompile skin js & invalidate JS cache

,

Hey there, I want to add some simple JavaScript to my skin which is derived from flamingo skin. I used the flamingo.js there to add a simple JS statement.

As I see it, the flamingo.min.js is not recompiled on startup and - as I did not dive into XWiki development so far - I am clueless how to achieve this.

Even if I do it “manually”, the cached version is always loaded. So my question would be how to invalidate XWikis cache, so that always the latest js version is loaded with the skin.

I read the documentation on “integrating javascript libraries” and “WebJARs” but this is would be total overkill to this little JS addition.

Any ideas? Thanks in advance! :slight_smile:

Update: I now used the infos from the SkinExtensionsTutorial and added a JavaScript-Extenson on the root page of the wiki (with caching policy turned off and usage in the whole wiki). This works fine in my case.

The only downside is that I cannot put my code to version control so I am still looking for a way to do this in the skin directory itself. If anybody has an idea how to

  • force recompilation of minified javascript files (from flamingo.js to flamingo.min.js and the sourcemap file)
  • invalidate the frontend caches

I would be overwhelmingly grateful.

Hello @johlton ,

you can create a new .js file and put it wherever you want on disk in the war (in the skin directory or elsewhere). Then, in order to make sure it’s included for all pages of your wiki, you’d need to modify javascript.vm from the skin (in the skin directory on disk) to add a new <script tag for your js file.

If your javasript is new code (not modifying some existing code of XWiki) it’s a much better practice to isolate it in a file of your own, so that when you upgrade XWiki to a higher version you don’t need to worry about merging between your modified file and the XWiki platform’s file.
You would need to do this merging for javascript.vm following this modification, but it’s much easier to merge a single line than a whole block.

Hope this helps,
Anca.