Posts Tagged ‘firefox’

How To Achieve Maximum Website Performance (Part 1)

Saturday, May 9th, 2009

The idea for this article came to my mind when I was wondering why twitter.com is so slow sometimes. When looking at the source code of my profile homepage on Twitter I was really shocked because I still cannot understand why such a reputable company with so many users does not use all of the methods and processes available to increase the performance of their website.

But first things first. Before you’re going to analyze your website to find out what you can optimize to increase the performance of your website you need to install the following addons and Firefox of course.

I have also compiled a comprehensive list of Firefox addons for developers but you only need the addons listed above to follow the steps described in this article series.

1. Finding The (Maybe Not So Usual) Suspects

It is important that you empty your browser cache first.

Now just open the website in your Firefox you wish to speed up.

At the bottom of the browser in your status bar you will see information collected by the lori addon.

Screenshot of "Life Of Request" info

Screenshot of "Life Of Request" info

Time To First Byte

The first value shows you how long it took for the first byte to arrive. On this blog’s homepage it took just about 0.157 seconds. If you have dynamic data on your page and maybe even database queries on your site the value may actually be much higher.

This value is important to optimize your code on the server side. If you see something like more than 0.5 seconds or even a value greater than one second you know that you have to optimize your server-side code (more on that later).

Total Load Time

The second value shows how long it took until all of the elements on the page had been loaded - this includes embedded images and everything else - even external scripts and embedded video players. If this value is higher than about two to three seconds you know that you need to optimize the code on the client side.

Total Number Of Bytes

The third value shows the total number of bytes transferred which also includes images, scripts etc. Depending on your site and your target audience this value may be quite high but in most of the cases it should not exceed 200K (if your site is a blog it may be up to 500K in my opinion).

Number Of HTTP Requests

The fourth value shows you how many separate HTTP requests to a server were required. Your goal should be to minimize this number. At the time of writing there were 37 HTTP requests required on this page (and 5 requests on reload which is shown in the screenshot) which is quite a large value. Every HTTP request (especially if the request goes to different servers) results in a delay of your page being displayed.

There is no rule of thumb regarding this value - it depends on the nature and contents of your site but it should always be as low as possible.

2. Optimizing The Time To First Byte

If the time to first byte value is quite high you need to optimize your server-side code. As there is no general rule for all the different backends, applications and content management systems I can only give general recommendations here yet I will also show you how to decrease this value if you are using WordPress on your own server (not the hosted blogs at Wordpress.com).

Static Page

If the page you are trying to optimize is a completely static page (like a real HTML file) and the value is relatively high I would interpret this as your server being too slow or being under a high server load. You should check this with your webhost as a static page should be delivered by webservers in a very short amount of time.

Dynamic Page

If your page is a dynamic page developed in PHP, Perl, Ruby-On-Rails, JSP or any other web development language or system there may be much to optimize depending on the nature of your page.

Do you have many content on your website that is retrieved dynamically?

You may for example have the latest comments by users in your forum, on your blog or the latest images or postings on your page. If you are not caching these contents (or the page) on your server yet just ask yourself the following question:

What is the access-to-update ratio, i.e. how often is the specific page accessed by someone and how often do you change or update the contents?

If you have many people accessing your page yet you only update it hourly or even daily or weekly you should implement caching on your server. You may for example just update the contents on the page every X minutes from the database or you may use what I call intelligent caching where you only update cache files if the content has changed. This is actually what I am using on most of my own sites: when a new user joins the cache file containing the HTML code for the “new users” snippet is deleted. Whenever someone then accesses the page the PHP script on the server checks if the cache file is available and loads it in that case. If it is not available it is created just-in-time, cached and will be used as long as it exists.

Implementing a caching algorithm is however very dependent on the language your code is written in and depends on your framework or application so I cannot go into detail on that matter, regretfully, as there is not a one-fits-all solution.

WordPress

I am using WordPress on this blog as well (as you might already have guessed) so I can give you some advice on how to optimize your pages.

I have seen many plugins for WordPress that have not been developed with getting lots of traffic in mind. Some retrieve the data from an external source (like your Twitter feed) on every single page request which not only increases load time it also means that your blog may be unavailable if Twitter (or any other source a plugin may be using) is down. This also leads to a huge amount of traffic to the external sources. You should check if the plugins you are using are requesting dynamic content from external sources on every single reload of a page.

Remember: whenever you access such a blog page data is retrieved from the external source before the page is displayed to the user (because it is server based). If these pages would be cached on the server for a limited amount of time this problem would be solved (to the most part).

There is actually a great caching plugin available for WordPress. It is called WP Super Cache and can be downloaded or installed directly from within WordPress. It decreases the load time of your WordPress pages dramatically because with the default installation WordPress pulls all article data on every request from the database so the database is really your bottleneck if you are getting lots of traffic to your site. WP Super Cache not only caches the pages it is also very intelligent in that it regenerates cache files automatically if you update your posts.

More info on WP Super Cache is available on this page as well.

This concludes the first part of the series. Continue to read the second part of this series.

tweetthis-15

Cool Firefox Addons For Everybody

Thursday, April 23rd, 2009

Previously I have already recommened must-have Firefox addons for web developers but this time I have just complied a list of some mostly very small addons I can highly recommend.

Copy Plain Text

Sometimes you’d like to copy some contents from a website into an email or something like Word. If you have ever done that (and your editor is not set to plain text) you know what happens. All of the contents are copied with the original styles like formatting, colors etc. Sometimes you just don’t want this and need only the plain text.

Before this addon was developed the obvious solution was to copy the contents, open something like Notepad on Windows, insert the text there, copy it again and insert into the final program like your email program or word processor.

If you have installed this addon you can simply right-click after selecting any text and instead of selecting “Copy” as you would normally do you can just choose “Copy as Plain Text” and you’re done.

Download Statusbar

I’m wondering why this hasn’t been included in Firefox from the beginning. For me it’s just a must-have addon allowing easy integration of download statuses, launching downloaded programs and so much more directly from within the Firefox main window - no need to open that download window anymore.

Flashblock

After installing the Flashblock addon in Firefox all the Flash objects on a website are disabled by default and replaced with a Flashblock placeholder. By clicking on this placeholder element the Flash object is executed as usual.

The downside of this addon is that you may need to click much more depending on which sites you’re visiting. However the addon also features an exclusion list of sites where you want to allow Flash content to be enabled automatically. For many months I have been waiting for a feature in Flashblock that - as I found out just a few weeks ago - is already contained in the addon. If you wish to allow a specific website you would normally have to open the addons dialog, open the Flashblock settings and then manually enter the URL of the website you wish to always allow Flash execution on.

This tedious task can be highly optimized by right-clicking on the free space next to the menu bar on your Firefox browser, selecting “Customize” and then dragging the Flashblock element into the Firefox navigation bar. Afterwards you can easily allow access for any site by using this button.

Forecastfox

Always want to know the current weather forecast? Then install Forecastfox - it’s small, cool and customizable. Nothing more to say I think.

Link Alert

Actually nobody I know seems to know this addon. I really like it. It actually does nothing more than changing the mouse pointer when hovering over a link depending on the target URL. This way you can actually see directly without looking at the target URL if the target is an SSL URL, a ZIP file, a PDF, if the link opens in a new window automatically and much more. Just have a look at the addon page to see some screenshots. I’m sure you don’t want to miss it after you have used it for some time.

Morning Coffee

Always visiting the same URLs every day on certain times or on certain days? Highly configurable depending on the weekday. Allows you to open specific websites according to a predefined list. I’m using it nearly every morning to automatically open the weather report and the current train schedule - I just need to click on the coffee cup in the navigation bar. Cool!

PDF Download

If you have installed the Link Alert addon mentioned before you already know prior to clicking on a link if it links to a PDF file. This addon shows a dialog whenever you click on any PDF link allowing you to choose between opening it directly, saving it to disk, converting it to HTML or bypassing this selection directly which means that Firefox handles the PDF link as if you had not installed the addon.

Save Image In Folder

Are you tired of browsing to the correct directory for saving images? When I download a desktop background image I just right-click on the image and select “Save in folder” and then “Desktop Backgrounds” which I have configured before. This is quite helpful if you have different folders for different images.

Session Manager

I am actually one of those people that like to see all the tabs opened before when the browser has been closed and is restarted. This is what the Session Manager can do. And even if your Firefox crashes (as happened to me just today) on restarting Firefox it will show a box where you can select the session that has been saved automatically - normally I just need to hit ENTER and the session that was active before the browser crashed is restored automatically.

I hope you found some interesting addons in this list - I can recommend any of them.

tweetthis-15

Must-Have Firefox Addons For The Developer

Monday, April 20th, 2009

Here is a list of Firefox addons for every web developer most of which I’m using almost daily. I can highly recommend any of these addons and I’ve been using most of them for a very long time.

Firebug

Nowadays I think I could just ask where you’ve been living for the past two years if you don’t know this must-have extension. Firebug allows you to debug your JavaScript code on your live website, to view and edit the HTML code and  CSS files on-the-fly directly for the current page and much much more.

Firebug also features am essential JavaScript console you can use in your own scripts for debugging and logging. Just check it out - it’s so essential that I won’t get into any more details here.

JSView

This cool addon adds a “JS/CSS” button to your browser’s status bar allowing you to see and view every single CSS and JS file that’s loaded on the current page. Sure - Firebug has the same feature, but using JSView actually makes this even easier than Firebug.

QuickJava

Quite often you have to check your own website to see if most of it still works if the user has JavaScript disabled. This addon adds to small buttons to your status bar which allow you to enable and disable both Java and JavaScript in your browser with one click. You still need to reload the page but this saves you from the tedious task of opening your browser settings each and every time you need to turn it off (or on).

HTML Validator

You should always make sure that your website contains only valid (X)HTML code and there is no easier way than installing this addon. This one also adds an icon to the status bar of your Firefox browser which is either a yellow warning sign, a green “ok” image or a red icon with a white cross indicating the validity of the code on the current website.

By double-clicking on that icon you are taken immediately to the source code view of the page including all of the warnings and errors that this addon has found in your code. Best of all - it checks everything offline, so it’s not sent to the W3C Validator and it’s very fast.

Live HTTP Headers

Sometimes you need to check the HTTP headers sent by your browser to the server or vice versa. This addon allows you to do just that and you can even apply regular expressions to the output so that you will only see what you are looking for.

Web Developer (Toolbar)

This is also a must-have addon just like Firefox which adds several features missing from your Firefox if you’re developing websites. Most often I’m using the “Find broken images” feature although this is just a very small part of this mighty tool.

ColorZilla

Sometimes you need (or want) to know the specific hexadecimal color code of a specific color on the website you’re currently on. ColorZilla adds a color picker to your browser and allows you to copy the color values directly to the clipboard so that you could insert it in your CSS file (that is what I am using it for most of the time).  And it still offers even more features that that.

MeasureIt

Draw a ruler to measure the width and height of any object on the current page.

SearchStatus

Would you like to know the current PageRank of the current website or the Alexa rank? This addon also offers additional features such as highlighting “nofollow” links and easy access to WHOIS and robots.txt information for the current domain.

SEOBOOK SEO  Toolbar

This is your ultimate SEO addon as it integrates as a toolbar into your Firefox browser and shows you almost anything of interest regarding SEO on any website. You can directly see the PageRank, Yahoo! backlinks, Yahoo! indexed pages, whether the current site is listed in the Open Directory Project (DMOZ), in the Yahoo! directory and so much more. You can even see the approximate age of the domain according to the first version indexed by the Internet Archive.

If you know any other cool addons for a web developer I would very much appreciate your comments and feedback.

tweetthis-15