Importing javascript file into my soy template

I have a soy template located in /resources/templates/template.soy. I’m trying to import a javascript that is located in /resources/js/chartsMaker.js and I tried the following and it didn’t work:

{namespace plugin.contributions}


/**
 * Contribution tab
 */
{template .contributionsTab}
    <html>
        <head>
            <script src="chartsMaker.js"></script>
        </head>
        <body>
            <h1>Hello World</h1>            
        </body>
    </html>
{/template}

Hi Murtada,
you need to declare your JS files as web-resources in atlassian-plugin.xml, best practice is to define a web-resource context and load the web-resource via its context in the soy template with

{template .contributionsTab}
{webResourceManager_requireResourcesForContext('my.plugin.resource.context')}

Hope that helps.
Best, Ulrich

1 Like