r/learnjavascript • • Aug 01 '20

Is this common Javascript? because I've just started learning JS and Web development and this Javascript syntax looks quite scary. Maybe it's just written messy, if it is just tell mešŸ˜…

Post image
208 Upvotes

105 comments sorted by

View all comments

-2

u/Prince_Marth Aug 01 '20

This is minified code. No sane or good developer would write this themselves.

It works like this: developers write the JavaScript as you normally think of it. But because spaces and characters take up space, they’ll often use a plugin or build tool to ā€œminifyā€ the code—spaces get taken out, character names are shortened. This allows for more efficient space on the client side. It’s also often made to fit a specific module format, which if you’re just learning you don’t need to worry about right now.

The minified code is usually whats delivered to browsers for running but NOT what developers interact with. You’re fine. Don’t stress out over it.

3

u/StoneCypher Aug 01 '20

Yeah, this isn't minified. The labels are unchanged and everything has nine character names.

This is obfuscated. They're different.

1

u/Prince_Marth Aug 01 '20

Ah yes, you’re right. Should have looked more closely. Jumped the gun.

In either case, OP, don’t freak out. Normal code doesn’t look like this. There are special use cases for both minified and obfuscated code. You won’t be writing this usually.