Tag Archive: Firefox


from http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r_2.html

As we all know an xmlhttp script requires the use of the readystatechange event. In theory, using the load event is also possible, but Explorer doesn’t support it on xmlhttp requests.

Both these events, and the readyState property, have a few odd quirks when used in an xmlhttp environment, though. These quirks don’t impact standard xmlhttp scripts too much, but as soon as you want to use the event objects or readyStates other than 4 you need to know about them.

readyState

The readystatechange event fires when the readyState of the request changes. This property can have four values, which theoretically work in the way shown below. In practice, though, the browsers don’t quite follow this de facto standard.

0 Uninitialized – open() has not been called yet.
1 Loading – send() has not been called yet.
2 Loaded – send() has been called, headers and status are available.
3 Interactive – Downloading, responseText holds the partial data.
4 Completed – Finished with all operations.

readyState 4 is equivalent to the load event and is a standard part of any xmlhttp script. I have never understood what the other three readyStates are good for; why would you need to know that responseText holds the partial data, for instance? One more mystery to solve.

That said, let’s try the following bit of script. You’d expect four alerts, 1, 2, 3 and 4.

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onreadystatechange = checkData;
xmlhttp.send(null);

function checkData()
{
	alert(xmlhttp.readyState);
}

Results:

  • Explorer: 1-2-3-4 (correct)
  • Mozilla: 1-2-3-4 (correct)
  • Safari: 2-3-4
  • Opera: 3-4

Where have the missing readyStates gone in Safari and Opera? I have no idea.

Let’s move the event handler assignment to a different point in the code:

xmlhttp.onreadystatechange = checkData;
xmlhttp.open("GET","somepage.xml",true);
xmlhttp.send(null);

Results:

  • Explorer: 1-1-2-3-4
  • Mozilla: 1-1-2-3-4
  • Safari: 1-2-3-4 (correct)
  • Opera: 1-3-4

All browsers now add an extra readyState of 1 at the start of their sequence. Explorer and Mozilla give a “1″ alert twice, and that’s odd, because the event name is clearly readystatechange and a change from 1 to 1 is no change. Opera still lacks the readyState 2. Odd, odd.

Let’s move the event handler assignment again:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.send(null);
xmlhttp.onreadystatechange = checkData;

Explorer doesn’t react at all if you assign the readystatechange event after the send() method has been called.

  • Explorer: nothing
  • Mozilla: 2-3-4 (correct)
  • Safari: 2-3-4 (correct)
  • Opera: 3-4

In conclusion, no browser correctly supports readyState in all cases. Fortunately the all-important value of 4 is unaffected by this odd series of bugs.

readystatechange

Let’s consider the events themselves:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onreadystatechange = checkData;
xmlhttp.send(null);

function checkData(e)
{
	var evt = e || window.event;
	var rs = xmlhttp.readyState || "None";
	alert(evt.type + ' ' + rs);
}

Now you’d expect to get an alert “readystatechange 1″ through 4. Unfortunately only Safari gives this correct response, even though it starts at readyState 2, as we saw above.

  • Explorer: “load 1″, then sometimes error messages, sometimes the “load 2″ through 4 you’d expect. Right now I think the error messages come when the XML document is being really loaded, and the 2 through 4 when Explorer can get the XML document from the cache.
  • Mozilla: error message: event object doesn’t exist
  • Safari: “readystatechange 2″ through 4
  • Opera: error message: event object doesn’t exist

The readystatechange event object is entirely absent in Mozilla and Opera, while Explorer feels its type is a load event.

Another related point:

When you use synchronous loading in Mozilla (ie. browser waits until the XML file has been loaded before doing anything else), the readystatechange event is not available.

This is not a huge problem, because the idea behind synchronous loading is that you wait for the XML file to be available, anyway. The line after the xmlhttp.send(null) is executed only when the XML is there. Nonetheless this point should be noted, too.

load

Explorer has a point in so far as the load event can be seen as a subset of the readystatechange event. load fires when the page has been loaded completely, which is equivalent to saying the readyState is 4: completed.

Let’s try it:

xmlhttp.open("GET","somepage.xml",true);
xmlhttp.onload = checkData;
xmlhttp.send(null);

function checkData(e)
{
	var evt = e || window.event;
	var rs = xmlhttp.readyState || "None";
	alert(evt.type + ' ' + rs);
}
  • Explorer: error message because you assign the unknown property onload to the xmlhttp request
  • Mozilla: “load 4″
  • Safari: “load 4″
  • Opera: error message: event object doesn’t exist

So Explorer doesn’t support the load event on xmlhttprequests. We already knew this, but we should realize it doesn’t even allow you to set the event handler, since it allows only a very limited set of properties on the xmlhttp object.

The event object is still missing in Opera, though not in Mozilla.

from http://www.davidtan.org/tips-reduce-firefox-memory-cache-usage/

Sometimes I just feel that Firefox is such a memory hog. Once I start to open up a few extra tabs, it starts to slow down my whole system. Fortunately, you can do something about it. Here are simple tips and tricks to reduce firefox memory and cache consumption.

Tip 1: Reduce session history
browser.sessionhistory.max_entries determines the maximum number of pages in the browser’s session history, i.e. the maximum number of URLs you can traverse purely through the Back/Forward buttons. The Default value is 50.
We usually won’t surf more than 5 of the websites we previously surfed before, and there is really no need to store more than that in the session which can clog up memory as they grow.
1. Open Firefox
2. Type about:config in the Firefox address bar
3. Press CTRL-F and search for browser.sessionhistory.max_entries
4. Double click on the value 50 (or whatever value is there currently) and change it to something lower such as 5.
5. Restart Firefox.

For Firefox 1.5 and above, you can also look at another configuration variable browser. sessionhistory. max_total_viewers which also determines the maximum number of content viewers to cache for “bfcache” (fast back/forward navigation). Default value is -1 (calculate based on available memory).
Set it to 0 so that no pages will be stored in memory.
set it to a number such as 5 to store only 5 pages in memory.
more info here

Tip 2: Reduce memory usage when minimize
1. Start up Firefox
2. Type in about:config in the address bar and hit Enter
3. Right click and choose New > Boolean
4. Type config.trim_on_minimize in the pop-up box and hit Enter
5. Select True and hit Enter.
6. Restart Firefox

Tip 3: Fixed cache capacity OR Disable Cache Totally
Every time new page is loaded, Firefox will cache the page so it doesn’t need to load again to be redisplayed. By default, this setting is set to -1 for browser.cache.memory.capacity and to a number you specified in Tools -> Options -> Advanced -> Network / Cache for browser.cache.disk.capacity

To fix your cache to a certain value:
*browser.cache.memory.enable and browser.cache.disk.enable needs to be True for this to work
1. Start up Firefox
2. Type about:config in the address bar and hit Enter
3. Search for browser.cache.memory.capacity and set a number in KB to use for the memory cache (ie. 1024KB = 1MB).
4. Search for browser.cache.disk.capacity and set a number in KB to use for the disk cache (ie. 1024KB = 1MB).

To Disable the cache Totally
Set both browser.cache.memory.capacity and browser.cache.disk.capacity to 0.
Alternatively, you can also set browser.cache.disk.enable and browser.cache.memory.enable to False.

Tip 4: Use less extension and themes
This is really a no brainer. Uninstall all firefox extensions and themes that you don’t use as they can cause Firefox to use more RAM. If you think that you might still need the extension in future but not using it currently, at least there’s an option to Disable it. Use only extensions that you usually use to cut down memory usage.

Always upgrade your extensions and themes to the latest version as they may fix the some problems leading to memory leaks. Firefox makes this quit easy as it now does the checking for you, all you need is to do is tick some checkboxes and your plugins and themes wil be updated.

Tip 5: Check Firefox Memory Usage
Type about:cache?device=memory in the address bar and hit Enter. Firefox will display your current number of entries, maximum storage size, storage in use and inactive storage.

There you have it. Happy browsing!

Just discover that when coding the following into style sheet:


table {
  border-collapse: collapse;
}
th, td {
  position: relative;
  border: 1px solid #eee;
}

In Firefox 3, top and right borders of each table cell will disappear.

In IE 7, borders could not collapse.

Don’t know why this happened, need to do a little bit more research.

Gears in Firefox

Just a note of gears in Firefox which will help a great deal in facilitating your web development.

Firebug: very handy extension which will help in figuring out the CSS and Javascript bugs.

YSlow: Y(Why) slow? It’s a really a good name which will clearly identify the performance problems in your web page. Why Google pages can response in seconds? YSlow will tell you the secret. For more information on this topic, go to YSlow support.

Live HTTP Headers: for those who feel more comfortable of working with http headers, this is it! Different from Firebug which provides console monitoring for Ajax interaction, Live HTTP Headers can give you more!

About protocol links

From http://kb.mozillazine.org/About_protocol_links

There are a few special URLs, which begin with about:, that you can type into the Location Bar. (In Thunderbird, which has no Location Bar, or in SeaMonkey, you can also use them as “Mail Start Page”.)

  • about: — The same page as “Help -> About”.
  • about:about — Lists all these about: URLs (Mozilla Suite/SeaMonkey only).
  • about:blank — A blank page. Useful for setting as your homepage.
  • about:bloat — Displays BloatView output (disabled in release builds).
    • about:bloat?new
    • about:bloat?clear
  • about:buildconfig — Reveals details about your Mozilla build options.
  • about:cache — Displays cache statistics and disk cache directory location.
    • about:cache?device=memory — Lists memory cache entries.
    • about:cache?device=disk — Lists disk cache entries.
  • about:cache-entry — Shows information about a cache entry. Used in about:cache links. Requires parameters.
  • about:config — GUI for modifying user preferences.
  • about:crashes — List of Breakpad crash reports, with links and datestamps. Only in products based on Gecko 1.9 or later (Firefox 3, Thunderbird 3, SeaMonkey 2).
  • about:credits — The list of contributors to the Mozilla projects.
  • about:logo — Displays the application logo (Mozilla Suite, SeaMonkey, and Firefox 3).
  • about:kitchensink — Was never included in Mozilla for the reasons listed in Bug 122411 (“Mozilla does not have a kitchen sink”). You can install an extension that adds it though :)
  • about:license — shows the Mozilla Public License and the Netscape Public License for the piece of software. ( Only in products based on Gecko 1.8 or later)
  • about:mozilla — The famous Book of Mozilla.
  • about:plugins — Lists all your plugins as well as other useful information.
  • about:robots — Easter egg, see bug 417302. Beginning with March 8th, 2008 trunk builds, it’s now available on Firefox 3.0b5..

Extensions

Certain extensions add a few additional about: URLs.

External Links

Powered by WordPress. Theme: Motion by 85ideas.