DEV Community

Discussion on: Hating jQuery will not make you cool

 
nitishk72 profile image
Nitish Kumar Singh • Edited

Yes, Vanilla JavaScript code is pretty ugly and I completely agree with that but using library just because your code doesn't look pretty is not a good idea at all. It will cost you a lot ( 30 kb).

Remember You can make the code more readable just by breaking it into function.

function ajaxRequest(url, params, callback){
    var request = new XMLHttpRequest();
    request.onreadystatechange = function()
    {
        if (request.readyState == 4 && request.status == 200)
        {
            callback(request.responseText); 
        }
    }; 
    request.open('GET', url);
    request.send();

}
    ajaxRequest('https://www.domain.com', null,function(response){
       console.log(response);
    }); 


Thread Thread
 
tobiassn profile image
Tobias SN

That was just an example. There could be a bunch of these cases in the code, and besides, 30 kB isn’t all that much anyway.