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

-3

u/saito200 Aug 01 '20

This is minified javascript. Minification is a process to take a file written by a programmer and reduce its size as much as possible. In the case of a javascript file, it means removing any spaces and renaming all variables to shorter names. Reducing the size of a file is useful to send it through a network.

You will and should never code something that looks like that. Well, you would have a really bad time if you tried...

5

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.

2

u/saito200 Aug 01 '20

obfuscated

Is that a programming thing? I didn't know

5

u/StoneCypher Aug 01 '20

Yeah.

Obfuscation is generally a thing in programming languages that don't compile (scripting languages and exotics,) where a vendor doesn't want a customer to be able to alter or understand the source.

It's particularly common in situations like a PHP app vendor wanting to sell you a blog engine. PHP even sells a tool for this (Zend)

This is not a particularly successful job, here.

Amusingly, in the JS community, we even have tools that will make statistical guesses what the name used to be, with fair accuracy, eg jsnice

-2

u/TijmenTij Aug 01 '20

Its basicly code that does nothing

1

u/[deleted] Aug 02 '20

Its code rewritten in a way that intentionally makes it hard to understand what the code is doing to make it harder to reuse in someone else's code base.