Skip to content

Unnecessary startup delay due to setTimeout in domReady() #5298

@Pankajyadav919

Description

@Pankajyadav919

###Description

The application startup is unnecessarily delayed due to the use of a fixed setTimeout(5000) wrapping critical initialization logic (setupDependencies() and domReady()). This introduces a noticeable delay before the UI becomes interactive, negatively impacting perceived performance and user experience.

Affected code pattern:

require(["domReady!"], doc => {
setTimeout(() => {
activity.setupDependencies();
activity.domReady(doc);
}, 5000);
});

This behavior was observed on initial page load, where the UI remains unresponsive for several seconds despite the DOM being ready.

###Expected Behavior

Lifecycle-critical initialization (such as domReady()) should execute immediately once the DOM is ready.

Only non-critical tasks should be deferred using proper idle mechanisms like requestIdleCallback or setTimeout(0).

The UI should render and become interactive as soon as possible after page load.

###How to Reproduce

Open the application in a browser.

Reload the page with DevTools Performance tab open.

Observe that the UI does not initialize or become interactive for ~5 seconds.

Inspect the code path where domReady() is wrapped inside a setTimeout(5000).

##Console log Errors:

No console errors are thrown.
However, performance profiling shows delayed execution of DOM-ready logic and event bindings.

##Environment:

Operating System: Windows 10

Browser: Chrome (latest stable)

Version of Software/Project: Current main branch

##Checklist

I have read and followed the project's code of conduct.

I have searched for similar issues before creating this one.

I have provided all the necessary information to understand and reproduce the issue.

I am willing to contribute to the resolution of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions