question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change the minified version of `undefined` to `1..u`

See original GitHub issue

This returns undefined, and it’s two bytes shorter than void 0 (it’s also 5 bytes shorter than undefined). The . operator has a higher priority than the void operator, so it’s safe. A plugin could also replace all instances of void 0 in other code with 1..u.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
loganfsmythcommented, Jun 20, 2017

Doesn’t seem like a good idea since everything would break if someone did Object.prototype.u = 4. We could hoist the definition with a var u = void 0; at the top of the file if there are more than a couple references to undefined though.

1reaction
ashsearlecommented, Jul 5, 2017

A little brain-dump for @loganfsmyth’s hoisting suggestion…

Remember that undefined is the default value for a variable, so this could be shorter at var u; or let u; (although I guess it would be more robust to use const u = void 0)

Also, there may be opportunities to piggy-back on a list of other variables declared, so could be as little as 2 additional characters. e.g. if a and b are already defined in a var a,b; declaration, then we only add ,u to get var a,b,u;

Or, if you want to use const for robustness, you place the const immediately after an uninitialised variable declaration: var a,b;const u=a;

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why would my global variable be undefined in the minified ...
It's worth looking through the minified version for the declaration line. I suspect what is happening is that the minifier has ...
Read more >
How To UnMinify JavaScript Minified Files Easily - YouTube
Sometimes you get a project with minified versions of JavaScript files being used in it, without source files. Minified version of files are ......
Read more >
What is Minification | Why minify JS, HTML, CSS files - Imperva
Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used...
Read more >
How to minify JavaScript - PageDart
When you minify your JavaScript you will improve your sites Page Speed. In this tutorial, we are going to look at how to...
Read more >
Enable minify setting that time I got js errors on console
This means that some file does not agree with being minified. You can check more details when checking that error. ... The alternative...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found