Get HTML img element reference by document.getElementById vs document.images

document.images returns a collection of the images in the current HTML document. Well, I assumed that it could be faster to get image reference by using document.images collection than just document.getElementById because document.images not operating on as large an HTMLCollection.

However, I made some test (on jsperf as well) and seems that document.getElementById method is faster in Firefox 22 and Chrome 27.0.1453.116 m, but not in IE 10.0.9200.16618 and not in Opera 12.15. All tests was done on Windows 7, 64bit.


As suggested b[……]

Read more

To cache or not to cache “length” property

I asked Thomas Lahn on comp.lang.javascript newsgroup about caching “length” property:

According to discussion here in your opinion property “length” still needs to be stored in variable before loop? Or this can be omitted because modern browsers caching (?) “length” property?

and he answered me:

One should never rely on what one cannot know. You cannot know the runtime
environments code once written will be exposed to. There i[……]

Read more

Clearing IE history, cookies and temporary files from command line

During my work I had to frequency cleanse the history, cookies and temporary files of Internet Explorer. Doing it manually it’s just annoying. There is a better way: use command line. So, create a clearie.bat file with commands:

:: Clear IE history
START RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
:: Clear IE Cookies
START RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
:: Clear IE Temp files
START RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

START command enables a user to start a separate window in Windows from the Win[……]

Read more

3 ways to check if object do not contains any properties (is “empty”)

During some tests I found at least 3 ways to check if object “is empty”. I mean, do not contains any enumerable properties. Assuming we have an object:

var obj = {};

Then we can use:

if(JSON.stringify(obj) == '{}'){
    // object is "empty"


if(Object.keys(obj).length == 0){
    // object is "empty"


var isObjectEmpty = function (obj) {
    for (var key in obj) {
        if (, key)) {
            return false;
    return true;


Read more

Don’t forget about “Expires” header

Why use Expires header?

Expires header tell the browser whether a resource needs to be requested from the source (server), or if it can be fetched from the browser’s cache. When we set an Expires header for a resource, such as all images, JavaScript files, or CSS, or whatever file we want, the browser will store those resources in its cache. The next time the visitor comes back to the page it will load faster, as the browser will already have those contents available in its cache, and will not need to download them from the server.


Read more

There is No Right Way to Develop Software

I like it:

Being a good developer means compromise. It means sometimes doing things one way for one project, and another way for another. It means balancing the needs of your stakeholders with your ideals. Sometimes they’re not always going to match up, but that doesn’t mean you should stomp the ground with your feet and have a tantrum when things don’t go your way.

The real key? Strong opinions, weakly held.

With that alone, you’ll go far.



Read more

Internet traffic control and monitoring tool

Sometimes our network connection is too fast for measure eg. “how my website is loaded”. In that case would be good to slow down our download / upload connection and test our loading website using slower connection. I use NetLimiter – Ultimate Bandwidth Shaper which provide me option for download and upload streaming.

Note: above software is designed only for Windows OS.[……]

Read more