Whist I agree with your intent, your very first example is a poster child for what's WRONG with JavaScript developers.

They don't know enough HTML or CSS to be using JavaScript. Since vanilla .js for a fade effect should be:

el.classList.add('fade');

With EVERYTHING else in the stylesheet. You don't waste JavaScript in 2020 on a flipping fade in/fade-out animation. Hell, many times you have things that would/should fade out -- like modal dialogs -- you wouldn't even use JS for that anymore!

Likewise is the card stacked ignorant JavaScript in the ajax example. innerHTML? REALLY? What is this, 1997? Much less why would you be hooking "click" on the button and not "submit" on the FORM? You just want alternate submission to bypass your scripting?

It's a mish-mash of nonsense gibberish code and certainly no way to handle a form submit! In EITHER version.

Though it could be worse, you could have said "who needs error handling" and used that promise asshattery.

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store