jQuery vs JS onchange

Benchmark created by tymeLX on


Description

Native JS v jQuery

Preparation HTML

<select id="colour">
  <option value="red">Nice red colour</option>
  <option value="blue">Cool blue colour</option>
</select><script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$("#colour").change(function() {
console.log(this.value);
});
ready
JS
document.getElementById("colour").onchange = function() {
console.log(this.options[this.selectedIndex].value);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by tymeLX on