How to pass string constants in UglifyJS as define argument

If you need to pass the constant number or boolean values in UglifyJS –define option, it is very easy. The tricky part is passing the string constant. Here is a quick code snippet to show how to pass string constant. uglifyjs “test.js” –define STRCONST=’”hello is a const string”‘ –output “build.min.js” The correct sequence is single… Read More »

How to use UglifyJS conditional compilation with reduce_vars

UglifyJS supports conditional compilation using the “–define” argument. Even though this option is good enough, it “looks” messy. The command prompt argument becomes too long and making an addition to the constant feels dreaded. Here is a quick way to use separate js file to define all your constants and use it in subsequent files.… Read More »

Randomize variable names each time UglifyJS runs

If you are using UglifyJS to uglify your JavaScript code, you are using it only to serve a single purpose – to make it hard for anyone to peek into your code. But if you have minor changes to the code, variable names still come out pretty much same. It is extremely easy for someone… Read More »

How to use JSDoc @event tag correctly?

I am using JSDoc 3.4.2 for my Javascript API documentation need. By looking at the @event tag example, when I tried to use it, the event name was replaced with “event:” + event name which was a sign that it was looking at the @event tag correctly but found two issues. When I use @fire… Read More »

JSDoc Tokenizer plugin to replace the token with values from config

If you are a Javascript developer, you would have used the JSDoc to document your Javascript code. I was trying to use the JSDoc for generating the documentation for my PramukhIME Javascript library. I have the core library and based on the plugin, I wanted to generate the documentation to show how the plugin works… Read More »

JSDoc – Customize output documentation files

I am using JSDoc 3.4.2 for my Javascript library documentation. I wanted to make the change to the output files so here are the tricks I used to make following changes. In order to make the change, I have copied all the files from the default template available at “C:\Users\USERNAME\AppData\Roaming\npm\node_modules\jsdoc\templates\default” (JSDoc over Node.js location) to… Read More »

How to use plain old JavaScript file into Node.js as a module

If you want to use your plain old JavaScript file into Node.js, you need to create a module which is nothing but a fancy wrapper around your JavaScript file and then you can use all the functions of your JavaScript object into Node.js. Environment Windows 7 (64 bit) Node.js 4.4.2 (64 bit) Path already contains… Read More »

Crash FreeTextBox using Javascript

Would you like to crash FreeTextBox? Here is the trick. Visit the page Click on HTML view and copy/paste the following code. Press “Save” button. This will convert your code into Note that “a” is missing. Pretty interesting!!! hmmmmmm…. Now again click on HTML view and copy/paste following code Now you will see error…..… Read More »

Be Careful When You Are Using Javascript parseInt() Function

First of all guess the result and then get the actual answer by clicking on the button “Show Result” In Javascript if the string starts with “0”, the string will be parsed as if it is octal number. (i.e. base 8) instead of decimal number(i.e. base 10). So if you are parsing the string containing… Read More »