Labels

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

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

Balanced parenthesis check

Balanced parenthesis check for expression using javascript

Given an expression with series of braces,curly braces and big brackets " () {} [] ", you have to determine that whether these parenthesis are balanced or not. If given a string " ({}) ", by looking at it we can clearly say that parenthesis are balanced. Today we are going to implement this using javascript. We will be using data structure stack.

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.