I have developed a sidebar app, and it is mostly working as expected. However, there are instances when the app fails to work and displays an “app is not defined” error.
Here’s the code snippet I used to initialize the app:
Upon encountering the “app is not defined” error, refreshing the page seems to resolve the issue, and the app starts working again. However, this is only a temporary workaround, and I would like to find a permanent solution.
It might happen because the appclient script is not properly loaded before rendering your JavaScript file in the sidebar location. The order of the imports and whether they are async matters here.
Could you share the head section of the HTML file of the sidebar location and the code where the other scripts loaded in any other part of the HTML file?
@Akhil_Moningii Could you move up the import statement for app.js to the last line within the head section?
Also, can you replace the fresh_client.js script import statement with <script async src="{{{appclient}}}"></script> as I have done?