I'm facing an issue where two JavaScript files linked to a single HTML document are conflicting with each other. It seems like the second JS file is always taking precedence over the first one. I suspect that this might be related to both files using window.onload, but I'm unsure of how to resolve it.
I attempted to use window.onloadend in one of the JS files and window.onload in the other, but unfortunately, the window.onloadend script ended up being the only one executing.
Here's a snippet from file1.js:
function initialize() {
applyFunction();
prefillForm();
var applyForm = document.getElementById("applyForm");
applyForm.onsubmit = validate;
}
window.onload = initialize;
And here's a snippet from file2.js:
function initialize() {
currentPage();
timer();
}
window.onload = initialize;