Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single letters for naming variables and functions

Context

I read a JavaScript code example written by Google. It used:

  1. Single lowercase letters for naming variables
  2. Single uppercase letters for naming functions

So the code was illegible.

Questions

  • Why this naming?
  • What tools are using to do this?
like image 488
GG. Avatar asked Mar 13 '11 21:03

GG.


1 Answers

Often when large Javascript libraries are put into production the code is "minimized" in order to...

  1. Decrease the download size
  2. Make it more difficult to reverse engineer the code

I think the primary motivator is #1 however.

This process generally involves things like removing comments and whitespace and changing variable references to single characters.

For instance, take a look at JSMin.

like image 192
Chris W. Avatar answered Nov 15 '22 22:11

Chris W.