How to add javascript library into jsReport

  • I want to try using a javascript library in jsReport.
    When I add the library to the <head> section of report and the library is an external library, it works fine:

    <script src=""></script> 

    But if I have the source of the library that I want to include directly in report, that is not working. I have tried adding javascript library inside the report folder and accessing it the following way but it does not work:

    <script type="text/javascript" src="/jsLibrary.min.js"></script>

    I have also tried adding the javascript file as an asset of the report and then using following code and it does not work:

    <script type="text/javascript" src=" {#asset jsLibrary.min.js}"></script>

    Any help will be appreciated.


  • <script type="text/javascript" src="/jsLibrary.min.js"></script>

    You would need to use path with file:///

    <script type="text/javascript" src=" {#asset jsLibrary.min.js}"></script>

    This would be like this

    <script type="text/javascript">
    {{asset jsLibrary.min.js}}
    {#asset jsLibrary.min.js}

    If the library is an npm module, you can use it also like this

    <script>{{module "moment"}}</script>

  • Thanks a lot for the reply.
    I got it to work with the following option:

    <script type="text/javascript">
    {#asset jsLibrary.min.js}

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.