Hi Vinutha,
Widgets are reliable and better than javascript snippets.
Have a look at the tutorial and documentation to have a better understanding of the lifecyle of both Custom(Dojo) and Pluggable (React) widgets. Though I must admit, this is not the easiest subject and not so well documented
Cheers, Andries
The document.ready() should be enough for running scripts right after dom loads. For debugging the normal debugger statement should work with any browser web inspector.
Have you looked at building your own widget?
Custom widgets use Dojo and you act on events at different stages of the page lifecycle. In this case, it sounds like “startup” maybe the event you need. Have a look at the Dijit lifecycle documentation for more information.
https://dojotoolkit.org/reference-guide/1.10/dijit/_WidgetBase.html
Pluggable widgets use React, but I’m afraid I’m not familiar enough with it to help here.
There is a client api available for what you want
mx.addOnLoad(function() {
console.log("You can use client functionality now");
});
You can find the documentation here: https://apidocs.rnd.mendix.com/8/client/mx.html