What is the best way to add Javascript to a Blocs site?

Title really says it all. I am interested in building a fairly complex webapp for use by small independent schools which will be javascript heavy. From what I have seen, in the webapp world in general, one does this typically by including a script tag just before the closing body tag and having your javascript in a separate file. Granted I am new to Blocs but this doesn’t seem to be working for me. Is there a Blocs-specific method I should be following?

Thanks!

You can add custom scripts by writing the scripts into a .js file and then add that file to the project using the „assets“ button which you can find somewhere to the bottom right of the app

A pop up will appear and in there a „+“ which when clicked let’s you add assets

DOC Page Attachments – Blocs – User Documents
Note I read there it says „attach to the head“ but I’m pretty sure that’s not the case for .js files since those should be added to the end of page.
I didn’t confirm as I’m on mobile thou…

1 Like

Great! This is what I was missing, thank you! I am still having trouble getting the js to actually work, but that is likely another issue :slight_smile: Thanks again!

Or… depending on whether you want the JS to be applied to all pages, or just one, you might want to try copying and pasting the JS onto the footer of the project or page using the code editor.