Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Chrome 115
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
jQuery test case 23569.2 Ops/sec
Vanilla JS test case 28557.7 Ops/sec
HTML Preparation code:
AخA
 
1
<script src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
Tests:
  • jQuery test case

     
    $.ajax({
      type: 'POST',
      url: "http://vanilla-js.com/path/to/api",
      data: {'banana': 'yellow'},
      success: (data) = {},
    });
  • Vanilla JS test case

    x
     
    const sendAjax = (url, data, callback) => {
        fetch(url, {
            method: 'POST',
            body: new URLSearchParams(data),
        }).then((response) => {
            const contentType = response.headers.get("content-type");
            if (contentType && contentType.indexOf("application/json") !== -1) {
                return response.json().then(data => {callback(data)});
            } else {
                return response.text().then(text => {callback(text)});
            }
        });
    }
    sendAjax('http://vanilla-js.com/path/to/api', {'banana': 'yellow'}, (data) => {});