How to integrate any JavaScript library or component in XWiki?
Last modified by Oana Florea on 2019/09/13
You can integrate any JavaScript library / component in XWiki. There are multiple ways to do this, see Integrating JavaScript Libraries in XWiki. The recommended way is to:
- install the third party JavaScript as a WebJar using XWiki's Extension Manager
- load the JavaScript using RequireJS
If there's no WebJar package available for the JavaScript library you want to integrate then you can load it from a CDN (such as https://cdnjs.com/ or https://www.jsdelivr.com) or from the file system (by putting the JavaScript code inside XWiki's unpacked WAR).
RequireJS implements the AMD (Asynchronous Module Definition) API so the easiest for XWiki is to integrate JavaScript libraries that support AMD. This is the case for instance with React (https://reactjs.org/).
Here are some examples:
- How to integrate React and XWiki:How to integrate React and XWiki.
- How to integrate Webpack and XWiki: How to integrate Webpack.js and XWiki.