Unicode JavaScript Variables and Functions
We all get a kick out of unicode symbols, as we all saw in my Unicode CSS Classes post, and just as we can use them for CSS classes, we can use them for JavaScript variables and functions as well! Let's say you want to shave a few bytes of post-minified JavaScript byes by setting false equal to a variable. Why not do so by using a unicode variable?
var ಠ_ಠ = false;
if(someVar === ಠ_ಠ) { // If someVar is false...
// ...
}
Hilarious. The evil eyes signal a negative result. What about saving a few byes on true? The Beatles once said that "All You Need is Love", so let's use a heart:
var ❤ = true;
if(someVar === ❤) {
// ...
}
You can do the same with function names. Functions can be named after unicode symbols:
function ಠ(arg) {
// ...
}
Of course all of this is a bit ... insane, and you should never use unicode symbols, but nonetheless it's possible. Imagine starting a new job and seeing those symbols as meaningful variables -- you'd quit immediately! Hilarious!
![9 More Mind-Blowing WebGL Demos]()
With Firefox OS, asm.js, and the push for browser performance improvements, canvas and WebGL technologies are opening a world of possibilities. I featured 9 Mind-Blowing Canvas Demos and then took it up a level with 9 Mind-Blowing WebGL Demos, but I want to outdo...
![Responsive Images: The Ultimate Guide]()
Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...
![jQuery Countdown Plugin]()
You've probably been to sites like RapidShare and MegaUpload that allow you to download files but make you wait a specified number of seconds before giving you the download link. I've created a similar script but my script allows you to animate the CSS font-size...
![Drag & Drop Elements to the Trash with MooTools 1.2]()
Everyone loves dragging garbage files from their desktop into their trash can. There's a certain amount of irony in doing something on your computer that you also do in real life. It's also a quick way to get rid of things. That's...
I could see this improving minification when processing files with many variables/methods in the same scope (if they don’t use it already, I’m not sure).
Unicode characters are useless for minification, each unicode character uses 2 bytes instead of 1 in utf8. Also, there is no reason not to use unicode in variable names if you properly declare encoding in your html.
Actually, some characters take up to 4 bytes, not just 2. The Kannada letter TTHA in the example rakes 3 bytes for example, so “false” was minified from 5 bytes to 7 :P
lol, it’s a funny joke. but I think it may be realize if some protocol is developed in the future. so cool!