Archive for March, 2009

Increase JavaScript Responsiveness with setTimeout

My current project requires moving an item from one list to another, and then verifying the contents of the second list against the database. In order to do this, I used the jQuery append function, and then called another function which executed a getJSON request.

Because the speed of the request was so slow, it ended up delaying the move of the item. This made the UI feel unresponsive. In order to fix this, I changed the call to the function to a setTimeout with a delay of 0. This meant that the UI could go on and do what it wanted to, while the JSON request went off and did it’s thing.

Tags: , , ,

No Comments


Browser Caching

As any web developer will know, caching is something that is both extremly good, and annoying in equal amounts. It’s good because it reduces load on the server and speeds up response times, but bad when you want to see your changes in a timely manner. Fortunatly there are easy ways to get around the annoying cache while developing sites.

First of all, you can disable your cache completly. In Internet Explorer this is done through the options menu, and in Firefox it’s done through ‘about:config’. This is the most extreme method, and something I don’t really recommend.

My prefered method is to use the Web Development Toolbar in Firefox, that comes with it’s own disable cache mode. However, sometimes even that is a bit extreme. A much simpler method (and one that works in all browsers) is to open up your css or js file in another tab, and simply refresh that tab.

Tags: , ,

No Comments



SetPageWidth