Javascript bundling and minification

Bundling is basically concatenating all small or big javascript and or css files into one huge file to minimize the number of requests and hence load on the server.

To speedup loading of a webpage bundling and  minification of the bundled code is necessary. Minification is the process of removing unnecessary characters like whitespace, comments, new line characters etc. from source code to reduce the overall size of the content without changing the functionality of the code.

So, less file size means lesser time to process and download files. Of course, there are various approaches to bundling and minification using bundlers like Webpack,  Browserify, RequireJS etc.

Advertisements

No Indispensable Man

Today is 1st May, Labour’s Day – an annual holiday all over India that celebrates the achievements of workers. But with AI(Artificial Intelligence), robots and machines trending in I fear Labour is put back by machines, not completely, though.

Yes! but future talks about taking it  over completely. Some thoughts on the same and also when you are in need of introspection, this is the poem by Saxon White Kessinger

Sometime when you’re feeling important
Sometime when your ego’s in bloom
Sometime when you take it for granted,
You’re the best qualified in the room
Sometime when you feel that your going,
Would leave an unfillable hole,
Just follow these simple instructions
And see how they humble your soul.  

Take a bucket and fill it with water,
Put your hand in it up to the wrist
Pull it out and the hole that’s remaining,
Is a measure of how much you’ll be missed.
You can splash all you wish when you enter,
You may stir up the water galore,
But stop, and you’ll find that in no time,
It looks quite the same as before.  

The moral of this quaint example,
Is to do just the best that you can,
Be proud of yourself but remember,
There’s no indispensable man.

The air is still free

“Out of the city and over the hill,
Into the spaces where Time stands still,
Under the tall trees, touching old wood,
Taking the way where warriors once stood;
Crossing the little bridge, losing my way,
But finding a friendly place where I can stay.
Those were the days, friend, when we were strong
And strode down the road to an old marching song
When the dew on the grass was fresh every morn,
And we woke to the call of the ring-dove at dawn.
The years have gone by, and sometimes I falter,
But still I set out for a stroll or a saunter,
For the wind is as fresh as it was in my youth,
And the peach and the pear, still the sweetest of fruit,
So cast away care and come roaming with me,
Where the grass is still green and the air is still free.”

By Ruskin Bond

AMD in Javascript

AMD stands for Asynchronous Module Definition. In a nutshell, it’s a format or a specification for writing javascript.

So, what is a Javascript module?

Its a reusable code which exports specific objects, making them available for other modules through dependency references to be used their programs.

These modules can be loaded asynchronously, if desired.  That means, there’s  a huge improvement in website performance as the files are only loaded when they are needed.  Also, it provides developers with the flexibility to define order in which module dependencies have to be loaded and load multiple javascript files during runtime.

AMD implementation is used by jQuery, Dojo, Firebug etc. There are various javascipt module loaders like RequireJS,  Browserify,  Webpack, SystemJS

Anyways, we swing

We swing our own swings
To and fro
Does it matter?
Less or more
and roar or adore
Anyways, we swing
Out of habit
Off bit 
Uncertain of how long
But certain enough
As long as our hearts beat

Composed by Vinit Desai

i18n, l10n

If any web application is to be used globally, it becomes very crucial to incorporate the internationalization (i18n) localization(l10n).

i18n is transforming the products and services enabling the flexibility to adapt support for multiple languages, cultures, currency, date formats etc. whereas l10n is adapting the internationalized products and services for a specific region and culture.

For example, a user from Russia wants to access a website which is currently in English but if the website is internationalized and localized into Russian. As a native Russian speaker the user might not be accustomed to the English language. This is where i18n and l10n helps a lot and user feels like home.

Round, ceil, floor : Decimal to integer

Javascript has inbuilt functions for converting decimal number to an integer value.

Math.round function is used to round a number to its nearest integer. If fractional part of the number >=0.5 then the argument is rounded to next higest integer.
If fractional part of the number < 0.5 then the argument is rounded to lowest integer.
Syntax: Math.round(number)
eg. Math.round(7.5) = 8
Math.round(7.2) = 7

Math.ceil function returns integer greater than or equal to a given number. Ceil means think of the ceiling of the room which is above your head.
Syntax: Math.ceil(number)
eg. Math.ceil(7.5) = 8
Math.ceil(7.2) = 8
Math.ceil(7) = 7
Math.ceil(-7.5) = -7
Math.ceil(-7.2) = -7

Math.floor function returns integer lesser than or equal to a given number. Floor means think of the floor of the room which is below you
Syntax: Math.floor(number)
eg. Math.floor(7.5) = 7
Math.floor(7.2) = 7
Math.floor(7) = 7
Math.floor(-7.5) = -8
Math.floor(-7.2) = -8