Kids: "Oh yeah! Cool and stuff!"
Professor: "First let's create a blank HTML page called
index.html, populate it with standard
body tags. Inside the
body tag place a paragraph with text 'Hello' and assign it an id
At this time we all knew HTML and CSS. No suprises here.
script tag. Bellow the paragraph add a new
script tag like so:"
<p id="message">Hello</p> <script> // </script>
script tag write the following and refresh the page."
document.getElementById('message').innerHTML = document.getElementById('message').innerHTML + ' World!';
We did what he told us. And we were amazed, and in shock. Some of us could not believe what was happening.
Kids: "Woooow! What else can we do with this?"
Professor said proudly: "Lots of things and stuff. But before we go any further, we will install jQuery and use that from now on."
Kids: "What is gQuery?"
Professor: "Go to jQuery website, download the file and place it next to our
index.html file. Rename it to
jquery.js so that our folder structure now looks like this:"
Professor: "Inside our
index.html we need to include jQuery. Place this code in the
Professor: "Now replace the code inside our previous
script tag to the code bellow and refresh the browser."
$('#message').text($('#message').text() + ' World!');
The rest is history.
The idea to write this post came to me about a month ago. I wrote it down on my whiteboard and it sat there until now.
var $ = require('jquery');
and then I start coding. This worked many times before. This time I was working on a template which already had jQuery loaded and to make matters worse I required a plugin using browserify which loaded a different version of jQuery. Somehow everything broke down. I could not initialize the plugin from browserify, but if I placed the code inside the html file it worked. It had also something to do with
This got me thinking.
Why do we still need it?
Is it evil?
Should we burn it on a stake?
Thank you for reading. I hope that you have had fun reading this as I had fun writing this post.