Limit on number of export functions one can have per page

Question:
Can I add as many export functions as I wish on a single page or is there a limit, e.g. 50?

Product:
Editor,
What are you trying to achieve?
To simplify my code, I am using export functions rather than cramming all events into the onReady function. All was well until I tried to add my 51st export function, at which point the editor simply refused to add the function and instead switched to adding just an event. What am I missing?

What have you already tried?
Tried to move the event to within onReady code, but so far no luck…
Additional information:
Such a surprise is very irritating. There is not a single word on any Wix/Velo forums/documentation about the limit on the number of export functions one can add to a page, and boom! I am hit with a limit at 50.

Hi, psaraph !!

I see, :thinking: I’ve never placed that many export functions on a single page, so I didn’t realize there might be a limit, but since limiting things to 50 is quite common in Wix, it’s possible that could be the case.

If you were to rewrite the code like this, would it work correctly? :thinking:

$w.onReady(function () {

 addEventFunc();

});

function addEventFunc(){

 $w("#someElem1").onClick(()=>{
  console.log("someElem1_Clicked!!");
 });

 $w("#someElem2").onClick(()=>{
  console.log("someElem2_Clicked!!");
 });

 // ...

 $w("#someElem51").onClick(()=>{
  console.log("someElem51_Clicked!!");
 });

}

I don’t believe it’s a limit but a change in the way the event handlers are defined.

I imagine previously you had:

export function onButtonClick(event) {
}

and now it looks more like:

$w("#someElem1").onClick(()=>{
  console.log("someElem1_Clicked!!");
 });

It’s to be expected and should continue working. No limits as far as I know

I see, I had noticed recently that the method for defining events has changed. Personally, I think this change is a good thing. :smiley: I had various concerns with the previous method. With the old way, if you copied an element with an event set on it and pasted it onto another page or site, there were times when the invisible event would remain without being removed, leading to unintended events happening, which was annoying. Now that everything can be done through Velo code alone, I think the possibility of such issues occurring is zero. I believe psaraph’s question could probably be resolved with this approach as well. By the way, does “continue working” mean that the previous export function style code will continue to work without any changes, or does it require rewriting? :thinking:

Thank you @noahlovell and @onemoretime !

Yes, the dynamic function works, but static ones are discontinued, it seems. I updated the code for the page I was working on, so now all static functions are dynamic, except for those that are called from within onReady function.