Would binding the same event to same element multiple times cause any issues?

Hi,

Let’s say I have script1.js and script2.js added on my page. Is the following acceptable use?

script1.js:

$('#form').submit(function() {
	// do something
});

script2.js:

$('#form').submit(function() {
	// do another thing
});

It seems to be working in my test, but wanted to ask others’ opinions too.

Use case: script1.js is a common script added to all pages, script2.js is unique to a single page.

Yes, JavaScript lets you bind multiple events of the same type to the same element. That is fully allowed.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.