HTML component onReady called twice

I have some fancy code that I need to run in an HTML component. I redirect flow to a third party application, which then GETs my “receipt page” which is a Wix router page. The “receipt page” is being displayed in the HTML component. The user can fill out a form on the “receipt page” and hit the Submit button. Problem I’m encountering is that the onReady() function is being called twice, and the submit_button_clicked is also being called twice. Each call comes at precisely the same time - see the timestamps on some of my console logs below. My guess is that this is a redraw issue on the GUI. While this is not fatal for what I need to do, I would like to at least understand why it’s happening because I hate mysteries. Even better, I’d like to avoid it. Anybody have ideas?

This will not be the error but have you read about the onReady firing twice?
https://support.wix.com/en/article/corvid-about-the-page-rendering-process
https://www.wix.com/corvid/reference/$w.html#onReady
https://www.wix.com/corvid/reference/wix-window.rendering.html#env

Also, have a look at these Stack posts.
https://stackoverflow.com/questions/10727002/jquery-document-ready-fires-twice/10727036
https://stackoverflow.com/questions/4107445/jquery-ready-function-is-called-twice

Thanks for the references. As you say, they don’t resolve the problem but good to know. Using this logging at the start of the method:
console.log("receipt page onready, env = " + wixWindow.rendering.env + ", random = " + randomizer(1000000));
I got the following:


(The randomizer function just gives a random number from 0 to the max value passed in as the arg). That’s weird, right? Browser environment in both cases, exactly the same time, exactly the same random number? My new theory is that the console log is repeating itself because the page is being hosted in an iFrame, so a console log is reported from the iFrame and then also from the parent window somehow.

Window rendering cycles is something that used to work, but appears to have broken at some point. I remember it being deprecated or something in the docs. This may be a remnant of that. In any case, for iframes I send a message to it on page load and once the frame receives it, responds with a ready signal. At the same time the ready signal is sent, some let/var is set to truthy value indicating the frame is loaded. That will help you avoid these errors.

@skmedia

Yes renderCycle and warmupData got deprecated.