Pages
Categories
Archives
Category Archives: post
“Even Faster Websites”
OReily Even Faster Websites is a great book. It has some Javascript perfomance hints in its “Writing Efficient JavaScript” part. Here are conclusions:
Use local variables
Avoid with statement
do not use too deep properies, redefine them with locals if possible
Use the if statement when:
— There are no more than two discrete values for which to test.
— [...]
Posted in post Leave a comment
take control over class constructor
Javascript doesn’t give us simple way to control object constructing. We have new operator, but we cannot control it. Unless we do some magic.
Lets assume we have an observer instance, few classes and we want every instance of this classes to be ‘observed’.
var observer=[]// simplest ever
function foo(){
this.foo="foo";
[...]
javascript constructor with arguments
There was an interesting question on stackoverflow recently. Nobody had right answer. Now after few days i got it! It is really a peace of JS art.
The question was if it is possible to call constructor like this:
someClass(arg1,arg2,...,argN){
.... //implementation
}
having just an Array of arguments [arg1,arg2,...,argN]. First thought was just to use apply. Next was: how [...]
SVG have a great potential.
What intriguing me most of all about SVG is the Adobe. Since SVG is a competitor to Flash. And Adobe was active contributor to SVG and then buys Macromedia in 2005. So I suppose there is a possibility that for Adobe will give up developing of 2 competitive technologies. And I think this won’t be [...]
Google Web perfomance initiative.
Gogle initiates a really great project recently: Let’s make the web faster
So Optimizing JavaScript code article got in scope of my interest.
Conclusions:
use [<string>,<string>,<string>].join(“”) for string concatenation (* this is pretty well known rule)
use prototype method defining rather than defining method inside closure
Creating a closure is significantly slower then creating an inner function without a closure, [...]
Javascript performance. Array vs Object.
Big JavaScript application needs big storage. JS gives us 2 options Array and Object. I have tested following cases:
writing data
writing data randomly
reading data
reading data randomly
I have tested this in following browsers:
IE
FF
Chrome
I want to point out that i am not comparing browsers. I am comparing two methods of storing data in JavaScript.
I have checked perfomance of [...]
JS features you better know 1