0

I have a question. I need to make some modification to our nette application (first time working with the framework). I need to import NAJA lib via FTP and by downloading code from github. I do not have access to server or console, so download via composer, npm... is not possible.

I done this:

  1. Downloaded all files from https://github.com/jiripudil/Naja/releases (not the ZIPs) and put them in directory vendor

  2. loaded in app/presenters/templates/@layout.latte with:

    <script src="{$basePath}/js/vendor/Naja.js" type="module"></script>

  3. Tried to inicialize it in one of my javascript with:

    document.addEventListener('DOMContentLoaded', naja.initialize() );

But then error pop up, saying that naja is not defined. What am I missing?

1 Answers1

0

Naja is written using modern JavaScript, it can be initialized only via ES5+ import, for instance

import naja from 'naja';

and then the event listener for initializing naja can be added after that code, and it can be compiled via webpack like this https://github.com/MinecordNetwork/Website/blob/master/webpack.config.js

You can do it all on your local machine with npm and yarn installed, and then upload bundle.js that was built to the server, it's also used in the mentioned repository so you can check out how and what libraries are needed, to compile the code from /public/js/main.js type yarn encore production or yarn build for development.