Tuesday, 30 September 2014

How to detect width of text inside text box

In this tutorial we are going to see how to calculate the width of text inside the text box. First of all we need to know why we are trying to achieve this. This is useful when you want to position some text suggestion just beneath the user cursor inside the text box. The image given below will provide better understanding of the scenario.

Wednesday, 20 August 2014

Javascript event capturing and bubbling

JavaScript uses two models for event delegation, capturing and bubbling. If you go back in old days, Netscape said that event on parent will take place first and Microsoft said that event on target element will take first. The W3C model combines both capturing and bubbling by saying that an event first makes its way downwards visiting captures i.e parent to target child and then bubbles back visiting non captures. Lets explore further

Monday, 7 July 2014

Enable gzip compression in apache

When a user types your website url in browser and hits enter, browser sends request to server. Server responds to that request in the form of reply by giving back the requested document. That document can be of any size, typically if we take javascript files, it can be between 100 to 200 KB. Is there is any way to reduce this size so that the downloading can be faster ? Answer is "yes", that's what gzip compression does. It compresses the document size to almost 70% of the original. The major benefit of gzip compression is that it reduces bandwith by reducing the size of the response from the server.

Sunday, 6 July 2014

How to minimize http requests

When it comes to website performance, number of requests made by your website to the server plays important role in total page download time. Since every request made includes round trip to server ( request and response ), it adds extra download time i.e total time spent during the trip. Also there are some limitations in the browser that how many parallel requests can be made to single domain. In a nutshell too many requests may decrease your website performance. Now we are going to look how can we minimize or reduce the number of HTTP requests.

Tuesday, 1 July 2014

How to speed up your website

One of the major concern of today's web developers is how to speed up their website. No one wants to wait for page download neither your user's too. Having fast website is very crucial in today's world, their is no place for slower websites. Below are some tips that you can follow to make your website blazing fast with minimal network load and fast rendering.

Tuesday, 24 June 2014

Javascript and garbage collection

Javascript doesn't have explicit memory mangament, it's the browser which decides when to clean it up. Sometimes it may happen that you experience unsmooth rendering of JavaScript due to a garbage collection pause.
There are many techniques that you can apply to overcome glitches caused by garbage collection (GC). More you apply more you explore. Suppose you have a game written in JavaScript , and every second you are creating a new object then its obvious that at after certain amount of time GC will occur to make further space for your application.
For real time application like games, which requires lot of space the simplest thing you can do is to reuse the same memory. It depends on you how you structure your code. If it generates lots of garbage then it might give choppy experience.