Adding custom scripts?

Hi all, I’m curious—how should I be thinking about adding custom scripts into WeWeb?

Is there any way to add scripts site-wide, or is this currently limited to a page-by-page basis (either by adding a custom HTML section or creating a workflow with a custom JS step)?

Where my mind is: in many website builders, there is simply an area to copy/paste code for analytics so it loads site-wide. Or in my particular case, I want to load Paperform’s JavaScript library site-wide so I can simply add the following to load as custom JS in a workflow action.

Paperform.popup('form-id', { prefill: { key1: 'value1', key2: 'value2' }});

Currently, I’m loading the library (code below) within the custom JS action. It works, however, I imagine this would be slightly faster if it were loaded in the background.

Should I separate out loading the Javascript in a custom HTML page element on every page it’s needed? Should I keep it all in a custom JS action? Or are there additional options I’m not thinking of (besides creating a custom component, which seems like it’s a little above my technical abilities).

(function() {
        var script = document.createElement('script');
        script.src = "https://paperform.co/__embed.min.js"; 
        document.body.appendChild(script); 
    })()

Paperform.popup('form-id', { prefill: { patid: '1234', ver: 'true' }});

Thanks!

Wes

1 Like

You can add custom code sitewide in the global settings.

2 Likes

:man_facepalming:

I can’t believe I missed that.

Thank you, Kevin!

1 Like