web development

Improve Website Performance

November 21st, 2012 0 Comments

Here’s a few basic rules to improve the performance of your website. Perhaps in the future I’ll go deeper into this topic and cover some more advanced topics.

1. Minimize HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate Scripts/Code
13. Configure ETags
14. Make Ajax Cacheable
15. Flush the Buffer Early
16. Use GET for AJAX Requests
17. Post-load Components
18. Preload Components
19. Reduce the Number of DOM Elements
20. Split Components Across Domains
21. Minimize the Number of iframes
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
25. Minimize DOM Access
26. Develop Smart Event Handlers
27. Choose over @import
28. Avoid Filters
29. Optimize Images
30. Optimize CSS Sprites
31. Keep Components under 25K
32. Pack Components into a Multipart Document
33. Make favicon.ico Small and Cacheable
34. Caching strategies like using Memcached
35. Serve resources from a consistent URL

How to install PHPUnit on Mac OSX

October 18th, 2012 0 Comments

The de facto standard unit testing framework for PHP is PHPUnit. You can find it here (GitHub repository). Even if the documentation explains how to install it on your system, it may not be as self-explanatory as it looks. Here is a little how-to for Mac OSX.

Get PEAR.
Open a Terminal window and type :

curl http://pear.php.net/go-pear.phar > go-pear.phar
This will copy the file we need to install PEAR on your local hard drive, in your User directory.

Install PEAR.
Still in Terminal, type :

sudo php go-pear.phar
Change the installation path (option 1) to

/usr/local
and launch installation.
After installation has completed, you can safely delete the go-pear.phar file.

Tell PHP CLI where PEAR is.
By default, PHP CLI (Command Line Interface) php.ini does not exist, but a template is available on the system. We have to copy and edit it. Type :

sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini
Uncomment the include_path line and make it look like this :

include_path = “.:/usr/local/share/pear”
Tell Terminal where PEAR is.
To let Terminal know where is your PEAR path and be able to launch PHPUnit right from the console, type (in the console) :

sudo nano /etc/profile
and add

export PATH=$PATH:/usr/local/bin
to the end of the file.
Save and exit. Close your Terminal window.

Install PHPUnit.
Open a new Terminal window and type :
sudo pear config-set auto_discover 1
sudo pear install pear.phpunit.de/PHPUnit
This will install all needed files for PHPUnit to run.

Enjoy.
Everything should be fine. In your Terminal, type :
phpunit
You should get a list of all available PHPUnit functions. Happy testing !

The Future Of Web Development

October 12th, 2012 0 Comments

The front end developer has realized that a new era of development is well formed and quickly coming.  With the introduction of technologies such as WebGL and Canvas, even graphics rendering became feasible using JavaScript.  But, this didn’t change anything on the server side; the server programs were still running on JVMs/Rubys/Pythons.

Fast forward to today: The scenario is dramatically changing. JavaScript has just sneaked its way into the servers. Now, it is no longer required that a web application needs to have a back end programming language such as Java/C++. Everything can be done using just JavaScript.

Thanks to node.js which made it possible to run the JavaScript server side. Using MongoDB, one can replace the need to have SQL code and now store JSON documents using JavaScript MongoDB connectors. The JavaScript template libraries such as {{Mustache}}/Underscore almost removed the need to have server side templates (JSPs). On the client side, JavaScript MVC frameworks such as Backbone.JS enable us to write maintainable code. And, there’s always the plain old JavaScript waiting for us to write some form validation script, and the never end JQuery plugins that extend our functionality with ease. With that, now it is possible to do the heavy lifting just by using JavaScript.

The front end JavaScript programmers no longer need to focus on just the front end. They can use their skill set to develop the web application end-to-end. This rise of the front end developers poses a threat to the survival of the back end developer. If you are one, do you already realize this threat? What’s your game plan to stay fit to survive this challenge?