Run details:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36
Chrome Mobile 114
Android
Mobile
one year ago
Test name Executions per second
jQuery test case 3260.5 Ops/sec
Vanilla JS test case 5396.0 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) => {});