The Age Of JavaScript

A Bleak Past

If you looked back just a few years ago, people weren’t sure what the end result of JavaScript would be. It was used primarily for abusive and very annoying purposes. We were plagued with alert boxes for all kinds of simple things, and confirmations boxes when we tried to leave a page. Unfortunately some of these bad practices still remain today, but luckily we’re in a time when the vast majority of websites (at least ones we willingly visit) use JavaScript to enhance the user experience, rather than for abuse.

Back then, the fate of JavaScript was a little unknown. Many browsers (IE) had JS disabled by default because it was seen at a potential security risk. Since so many users had it disabled, developers were unable to really rely on it. We couldn’t make a website that depended on JS for functionality because we would be excluding too many people. It was because of this that there was a lack for practical uses.

Acceptance

Now, just a few years later, it’s very clear that JavaScript is here to stay. In the past few years we’ve seen incredible innovations on how to use this amazing and versatile programing language. The introduction of libraries like jQuery, MooTools, and Prototype around 2006 began the acceleration process towards a more JavaScript dependent web.

Then, in 2007 the gas pedal was really pressed. With the introduction of the iPhone which didn’t support Flash, developers who were once dependent on this non-semantic software were forced to adapt. It became clear that the future would be in JavaScript, along with what was only the conceptual frameworks of HTML5 and CSS3.

Its Finally Time

Now, in 2014 we’re in the “Age of JavaScript”. We’re finally at a point where we can make websites that are fully dependent on the user having JavaScript enabled. New innovations and ways to use it, along with libraries and plugins are created every day. Its gotten to a point that if you don’t know JavaScript, then you can’t consider yourself a front-end developer.

What advantages are there to a JS dependent web? Well, I’ve recently been in the habit of using it in a unique way for form validation. I don’t mean the typical validation that most developers agree is barely Ok as a “first line of defense” against legitimate people who just forgot to enter some information, but is completely useless against spammers. I mean setting up the form so that it can’t be submitted without JavaScript being enabled. This can be done a few ways, but check out this very simple example:

<form id="myform" onSubmit="return validate()">
<input type="text" id="email" placeholder="email">
<input type="submit">
</form>
<style>
#myform {display:none}
</style>
<script>
document.getElementById('myform').style.display = 'block';
function validate(){
   if (document.getElementById('email').value.length < 3){
   return false
}
</script>

What I did here is pretty simple. First what I did was hide the form with CSS, then made it visible again through JavaScript. Then I checked to make sure that there's at least something in the email field before submitting.

This will stop a good amount of spammers right away. Why? Because in the example above, the user would need JS enabled in their browser to see the form in the first place, then if you validate the form using JS, you'll know that the user needed to go through the validation process. Is the above example perfect? NO, it's far from it. It's only a very simple example to get you thinking about the possibilities of a JavaScript dependent website.

If you're interested in learning JavaScript, you can take my course on Udemy. You'll learn everything you need A - Z. This course usually sells on Udemy for $150 but just for my blog readers, its available for only $40. Just follow this link to my JavaScript Course which already has the discount applied.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>