Interactions in js file?

Hi all! I just try pinegrow and saw on the website the interactions module.

I wonder if it is capable to exclude the required JS to a separate file (like with css). All videos I saw indicate that this is embeded in HTML.

best regards

Yes this is probably not a recommended use-case the inline JavaScript can be handy as it’s fast!)

In your project file inspector, click on the downward arrow and click “Create new file…” and name it something with the .js affix.

This’ll create a new JavaScript file where you can paste all that tasty JavaScript code.

Then on every page you wish to include this file (or in a master template) put the following HTML…

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

viola!

If of course you create/move your JavaScript file to a folder, you’ll need to reflect that in the src attribute.

<script src="/FOLDER/FILENAME.js" type="text/javascript"></script>
1 Like

Why do you want to exclude this?

For me HTML = Content and CSS = style and JS = Logic. I follow the principle of “separation of concern”.

Since e.g. CSS was invented, it was the idea to separate those things to have things clean.

For me it is a mess to have all in one file. As long this is in pinegrow “interactions” the behaviour to embed that in the html, it is nothing I need/want.

Fair. While it’s generally a good rule, it’s not hard and fast. Practically there are some technical implications as to why it’s placed in this way. Specifically the code needs to be ready and executed as soon as the page loads.

You shouldn’t be touching this code either so therefore it’s not a concern of yours to need to separate.

hmm, sure. I often did the trick by adding the script tag to the end of the HTML with an initial part that finds the then already loaded tags to apply the required event-listeners.

Yes, a tricky thing might also be, if multiple pages would share the same JS file.

I understand the benefit of loading it fast. But IMHO if I want to improve that, I would introduce gulp or grunt to optimize a single page to a kinda compressed snowball.

I will monitor future releases of it and see what is comming and if it triggers me. But thanks for your attention and opinion. But anyway, the editor itself is something great I missed since I used Dreamweaver many years ago and so I decided to buy it.