Javascript functions from the panel

I’d love to be able to reference and initiate a javascript function via the panel, perhaps with a built editor?

1 Like

Hi Buttholio,

what we definitely will add is an additional action “Call Function” for the events.

But I think you mean to fire some code on the DOMContentLoaded event for a specific page? I think it’s a good idea. The only question is how it will be integrated. I think custom code is a bit difficult for non-programmers. It would make sense to offer a few pre-built options, of course with the expert option for developers to include their own JavaScript code as well.

Do you have some ideas what such pre-built options could be once the DOM is loaded? In that case, it is about possibilities that are encapsulated from elements. Addressing elements after the DOM is loaded already works now (Event: Pageload).

2 Likes

There is something that I use some quite of a lot.

It’s calculate the height of the header to take it out from the main content.

Like that I can have a main section with something similar at:

.hero-section {
height: calc(100vh - {header height})
}

I even have it in a pen:

Maybe this is one of the functions that can be added in this pre-build options.

2 Likes

The javascript function would tremendously help to add analytics events to elements like buttons, views, scroll position, etc. We could add Plausible custom events, for instance. Other custom tags are also possible. It would be much easier than using an external tag manager.

3 Likes

The possibility to call JavaScript functions from the panel will be included to the version 0.9.2 :+1::blush:

4 Likes