stoimen.com/blog

web developing

Archive for December, 2009

jQuery live() vs bind() performance

1. What is event delegation in JavaScript?

To start with some example let’s assume that there is one DIV element with 100 A tags inside. If you assign event to every A tag that as you may know slowes down your browser. That’s a problem because sometimes that can happen, even with more than one hundred A tags. Imagine you’ve a map with one thousand markers, which are A tags. Attaching events slowes down the browser, because every of these A tags bubbles the event that has been fired. And that makes your CPU to make thousands of calculations. Of course you can avoid this problem with a simple technique. Just attach one single event on the container DIV element. Thus you can check if some child of the DIV element has been the target of the event. This makes the browser to breath. (more…)

We all know, or at least all of us reading every new coming news on the web development sky, that making your browser reflow and repaint is expensive. Actually it is quite expensive.

What I’m about to say comes under the tag of “very good news” for those how didn’t know what repaint as and what cssText is.

When it comes to the repaint and reflow, which sounds really strange, there are lots and lots of articles what this is, but in breve, just to let you know what is and where’s the bad part of it I’ll describe it again. (more…)

Recently I posted about the redirecting mechanism of Zend Framework. It’s a working chunk of code but the problem is that it seems quite difficult in according with other ZF sample codes.

Yes the same goal can be achieved with less effort. Like the _forward function which just executes other action/controller, you can call the _redirect method to rewrite the URI.

Just use that in any action of any controller:

$this->_redirect('http://www.example.com');

That executes exactly the same as calling the header PHP method or echoing the <meta> refresher!

If you ever wondered what your browser height and width is, don’t waste your time anymore but check it out with JavaScript. Actually there’s a difference, normally, between document height and the browser height for instance. The document can be higher than the browser, and that occurs when there’s a vertical scroll on the page.

In fact it’s quite easy to get the browser height and width (what we see as the white part of a blank page).

Simply check that out by dumping:

window.innerWidth & window.innerHeight

First of all, let me introduce you to my case. I’m working on a Mac with both Xampp and Zend Server CE. Both have separate MySQL servers installed from their default installation on my machine. Both have their separate phpMyAdmins.

The one thing I couldn’t find in the man page of Zend Server CE is how to I access this MySQL server installation from my PHP scripts.

The answer is quite simple – trough UNIX socket. The ZS CE default db socket is:

/usr/local/zend/mysql/tmp/mysql.sock

and yet again let me say that this is for Mac.