Hi, I'm Yaakov Chaikin. I teach grad web development at Johns Hopkins University and on Coursera.org.
By day, I am a software developer.
thumbnail for article on Why Is jQuery's Min Code Such a MESS?!

Why Is jQuery's Min Code Such a MESS?!

1 min read |
| by Yaakov Chaikin

That was the question asked by one of the almost 20,000 students in my Coursera course. He wanted to know the purpose of this mess. A perfectly legitimate and good beginner question to ask!

The answer, of course, is simple. It’s a product of taking the regular jQuery Javascript code and putting it through a process called minification, which takes out spaces, shortens the variable names, etc. All of this is done for the purpose of getting the file to be as small as possible to save on download time when the user loads the web page.

However, I must admit that I’ve never heard it expressed that way before: a mess! So, today being Friday (and April 1st!), my overactive humor gland started pumping out all kinds of ideas for how I could have answered that question.

So, here are the TOP TEN REASONS with which I could have answered the question of For What Purpose Is jQuery’s Min Code Such a Mess?!

(drumroll please)

#10. That code was written before there were code style guides.

#9. It IS a mess! I’ve created an issue for the jQuery team to fix this immediately!

#8. That’s John Resig’s URL-encoded soul… DO NOT. CHANGE. ANYTHING!

#7. That’s Javascript translated into Java, compiled into bytecode, then translated back to Javascript because of some trademark issues Oracle’s lawyers worked out when they acquired Sun Microsystems and Java.

#6. Are you using Windows? Try restarting the computer and see if that issue goes away.

#5. If you get good enough, you’ll be able to write code like this one day. For now, just use spaces, I guess.

#4. Do you use anti-virus? That looks like the Minification Virus at work. That’s been going around lately.

#3. Oh, I fell asleep on my keyboard while looking at that file. I roll around in my sleep. Sorry!

#2. It’s an encrypted message to the browser to behave itself. That’s why jQuery works so well across all browsers.

And the #1 reason is…

#1. The purpose? Job security! We cover that in the “How to Write Code For Job Security” lecture in the next module.

Do you have an answer you want to share? Leave it in the comments below!

Happy End of the Week! 😃

-Yaakov.

P.S. Sign up for my self-paced course HTML, CSS, and Javascript for Web Developers! Sign up or share it with someone who may want to sharpen their skills for FREE. We go pretty deep and make it easy at the same time!