ADM Blog

Read/Load files from ZIP in JavaScript

At work we do a lot of JavaScript applications that have little to no HTML files (beside the index), everything is generated by JavaScript and we have tons of .js files that load at runtime and to reduce the size we have to minify them and that is really hard to debug and watch in the browser if something goes wrong. So I've made this JavaScript class that comes to help. What can you do is Zip up all your assets (js, images, css) and use ZipLoader class to read the zip and unpack your resources whenever you need them. It's small (10KB), easy to use and quite fast considering the extraction is made by JavaScript.

   // loads and caches the zip file
   var loader = new ZipLoader('');
   // creates a style node in the document header and appends the style
   // creates a script node in the document header and appends the script
   // returns the file content
   var someFileYouNeed = loader.load("");
   // returns the base64 encoded image usable as img source
   $("#logo").attr('src', loader.loadImage(''));

The level of compression using zip surpasses the js and css minification in all the ways possible. For example, My current application has 79 files (js, and few css) and they all sum up to 924KB in size. Zipping all those 96 files using Ultra compression level gives me 1 file of 126 KB => 1 server request. That's something.

The best performance is made Opera (strangely), then Firefox, Crome, Safari and last IE (no surprise here, I was expecting it before I even started).

It's a V 1.0 that still needs some work and it doesn't work in IE because that stupid browser overrides the mime type and at first null character in the reading of the zip, the content ends. I will fix this eventually :) I will also include this as a jClass library soon.

Update: Fixed it so it works in IE as well. There is a performance issue still. Will fix that too.

Till then, HERE are the sources and a demo.

The zip in the demo is made using 7Zip with Ultra Compression level.

Happy codding.


10 Firefox add-ons for web designers

Firefox has emerged victorious from the Great Browser War - at least as far as web developers are concerned. While it may not be the most-used browser for the everyday web surfer, Firefox is clearly the first choice of developers for a few very simple reasons. Its support for web standards is legendary, but the real super powers come from Firefox’s extensibility. With a plethora of add-ons and extensions, created for developers by developers, Firefox becomes much more than just a browser and turns into an essential part of your toolbox. Rather than digging through your source code with squinted eyes, use Firefox add-ons to pinpoint Javascript errors and debug them like a pro. Use add-ons to measure areas of your page, select colors directly from the site or view the specific CSS assigned to a pesky

element. You can even get a leg up on assuring your sites are accessible and use valid markup - all thanks to Firefox’s add-ons.

Here are 10 free add-ons covering everything from DOM inspection to screenshots, making designing and developing with Firefox a breeze.

1. Firebug + Firecookie + Codeburner

The first on our list of 10 is actually 3 separate add-ons but they are all meant to work together, and when combined they form one of the most powerful development tools available.

11-150x150First and foremost, if you’re doing any sort of Javascript development Firebug is essential. Otherwise you’re really just stumbling around in the dark when it comes to debugging. Firebug not only gives you a robust error console, but also lets you add breakpoints in your code. Firebug’s HTML and CSS inspector gives you the freedom to either browse your source code in a collapsible tree, or click an element within the page to see its markup. Firebug also lets you edit your “live” HTML and CSS and instantly displays the results for you to review - no reloading, no saving.

12-150x150Install the Firecookie add-on and Firebug gets a new super-power: complete cookie viewing and management. You can view the full content of each cookie, and even edit and delete them all from Firebug’s window.

Codeburner then rounds out the Firebug setup by adding a compete W3C reference lookup with search-as-you-type on HTML elements & attributes as well as CSS properties. Ever wonder which browsers support the text-transform CSS atrtribute? Codeburner will tell you that it’s buggy in IE7, but has full support in Firefox 3, Safari 3 and Opera 9.
Here are 10 free add-ons covering everything from DOM inspection to screenshots, making designing and developing with Firefox a breeze.

Download: Firebug, Firecookie, Codburner

2. Web Developer Toolbar

If writing Javascript without Firebug is like fumbling in the dark, building a site without the Web Developer Toolbar is like blindfolding yourself, tieing your hands and and trying to run through the woods without hitting a tree. Disable your cache, images and cookies, switch style sheets by media type, auto-fill forms with temp data, outline certain element types, resize the browser window to common sizes and validate your markup - all from within one toolbar. The Web Developer Toolbar does a whole lot more and is always the first add-on I install in Firefox. Give it a try and you’ll wonder how you ever got along without it.

Download: Web Developer Toolbar

3. Measure It

3-150x150Ever need to know just how much space you have for a photo, or how wide a dynamically sized column is? This handy little guy lets you measure, in pixels, any area on the page. Super simple and super helpful.

Download: Measure It

4. Colorzilla

Another very simple but very useful add-on that displays the RGB and HTML color codes directly beneath your cursor. With a click, Colorzilla will copy the HTML color code to your clipboard for use in your favorite editor.


Download: Colorzilla

5. CSS Viewer

5-150x150CSS Viewer takes one of the features in the Web Developer Toolbar and makes it a little easier. Just point your cursor at any element on the page and CSS Viewer will show you all of its CSS attributes, from size and position to fonts and colors, all in an easy to read overlay.

Download: CSS Viewer

6. ScreenGrab

6-150x141A simple screenshot tool, Screengrab will save the visible area or the complete page as a file on your desktop. You can choose to save as a png or jpg, and even auto-add a datestamp to the file name

Download: ScreenGrab

7. Gridfox

gridfox-150x150If you use grid layouts or want to learn how, Gridfox is for you. It displays a simple overlay on your page to help you align elements to both vertical and horizontal grid lines. You can easily set the column and row sizes and spacing, choose from left-aligned, right-aligned or centered layouts and set the opacity of the overlay.

Download: Gridfox

8. User Agent Switcher

9-150x150If you swap style sheets or display alternate content based on which browser the user is viewing your site with, this add-on will tell Firefox to pretend it is another browser. Choose from Opera, Internet Explorer, or add your own custom user-agents to the list.

Download: User Agent Switcher

9. PageDiff

10-150x150Those of you familiar with the linux/unix “diff” command will instantly understand what this add-on does. Compare the source code of any two pages and see where they differ. This is very useful when comparing staging and production environments, or comparing a backup to a current deployment before restoring any code.

Download: PageDiff

10.  Cache View and Cache Status

1208087359CacheView is a GUI Front-end of "about:cache" that allows searching,sorting and saveing memory and disk cache files. Very usefull when 1) You want to see what is in your cache and 2) Save things from memory or disk cache since firefox has a very cryptic way of storing it's cache.

Cache Status is a customizable presence to your browser window's statusbar that gives you up-to-date information on your browser's cache usage, both RAM and the hard drive. The presence also has a right-click context menu, where you can easily clear your 943948800browser's cache. It can also automatically clean your cache when it reaches a specified level, through its Options.

Download: Cache Viewer, Cache Status


Really useful firefox keyboard shortcuts

firefox-shortcuts-mark1. Automatically complete .org and .net addresses

Yes, we know that if we type ‘google’ in the address bar and press Ctrl+Enter it directly goes to . But what about .org and .net addresses? .

In Firefox, Shift+Enter takes you to .net

And Ctrl+Shift+Enter takes you to .org addresses automatically .

2. Alt + D or F6

You can use this to navigate directly to the browser address bar of firefox. Very useful.

3. Ctrl+T and Ctrl+Shift+T

Ctrl+T helps you to open a new tab and Ctrl+Shift+T reopens the last closed tab.
This comes quite handy in case you accidently close a tab. Another way to do this would be go to History -> Recently closed tabs.

4. Alt+Enter

This can be an extremely useful shortcut. It automatically opens a website in another tab when you highlight it in the autocomplete list. For example you want to go to Facebook and you start typing www.face…, in the address bar and it starts showing the list below. You just need to use the down arrow key to highlight the selection ( in this case ) and press Alt+Enter so that it opens in a new tab.

5. Use of Delete Key

The Delete key can be pretty useful because it helps you delete specific addresses in browser history or autocomplete forms.  If I want to delete the 2nd entry from autocomplete history, I’ll just point to it and press Delete key. Simple, isn’t it .

6. Ctrl+Tab

Ctrl+tab helps you to navigate between different firefox tabs quite easily.

7. Ctrl+[1,2….9]

Ctrl+tab can help you navigate alternate tabs but if you are a heavy tab user like me and want to go to a specific tab then just use Ctrl+corresponding tab number. Ex:To go to the 3rd tab use Ctrl+3.

8. Spacebar and Shift+Spacebar OR PageDown and PageUp

Spacebar or PageDown key scrolls down the webpage you’re on and Shift+Spacebar or PageUp scrolls up the webpage you’re on.

9. The Middle Mouse Button

This is not a keyboard shortcut but it is an excellent shortcut. Just point to a link anywhere on a webpage and press the middle mouse(scroll) button. It opens the page in a new tab .Also middle-clicking a tab with the mouse closes the tab.

10. / Button

This (backslash) if you hit that once will bring a quick find option. We dont have to puch CTRL+F for searching.

I hope these shortcuts will enhance your browsing productivity with Firefox. Share your other interesting shortcuts which I may have missed....!


How To – get Cross Browser Compatibility Every Time

Working with Internet Explorer can be a pain for the everyday web designer. But it doesn't have to be. Many, if not all, of the bugs can be fixed quickly and easily by understanding how the occur. I've put together a list of the major problems beginners have with cross browser compatibility.

I'm only going to be concerned with the major browsers - Firefox 2+, Safari 3+ and Internet Explorer 6+. IE6 is slowly declining.  If you know the IE6 bugs you can generally know if your site will break before you even check it in a browser. This isn't an article for the super-experienced web designer, but hopefully will give some insight to some people who don't understand the mysteries of IE6 and cross browser compatibility.


Here is a quick summary for those of you who don't want to read the whole article:

  • Always use strict doctype and standards-compliant HTML/CSS
  • Always use a reset at the start of your css
  • Use -moz-opacity:0.99 on text elements to clean up rendering in Firefox, and text-shadow: #000 0 0 0 in Safari
  • Never resize images in the CSS or HTML
  • Check font rendering in every browser. Don't use Lucida
  • Size text as a % in the body, and as em's throughout
  • All layout divs that are floated should include display:inline and overflow:hidden
  • Containers should have overflow:auto and trigger hasLayout via a width or height
  • Don't use any fancy CSS3 selectors
  • Don't use transparent PNG's unless you have loaded the alpha

Element Inconsistencies

Every browser renders particular elements differently - different amounts of padding, margins, borders etc. This means your site can look different in every browser if you use default styles.


The first thing you should do, which most people most likely know about, is to reset your styles. A reset is some css you place at the start of your styles that removes the padding, margin, border and other inconsistencies from elements, and rebuilds them in a standard way.

Download Eric Meyer's reset.css and place the code at the start of your styles. Bam! Clean, cross browser styles.

Image Rendering

IE6 and IE7 both render resized images extremely badly. When you change the size of an image with CSS or in the HTML, it appears blocky and edgy.

Don't do it. Always size your images to your desired size before you use them on your site

Font Rendering

I told you not all issues were with IE. Safari 3+ has an issue with the way it renders light type on a dark background. Some would argue whether this is good or bad, but there's a way to make it appear lighter. Here's an example of standard white on black text rendering in Safari 3.1:


Easy fix. You need to add this to your code.

p {
   text-shadow: #000 0 0 0;

Where #000 is your background colour. You will probably have to be more specific with the elements you select. I wouldn't suggest using this fix on the body tag. Other elements you might need to fix are the li, dt, dd, blockquote etc. Use this on any text element you want to appear 'thinner'

To make this fix in Firefox, you use the opacity fix:

p {
    -moz-opacity: 0.99;

You need to be careful with this fix, as it will break any Flash element that it touches in Firefox. There appears to be no workaround for it.

The type will now be rendered like this:


Font Selection

There are common web fonts that we use - Arial, Georgia, Verdana etc. But there are some fonts that are common to both PC and Mac and can be used - Century Gothic, Arial Narrow etc. However, different browsers and OS's render type different, and you need to be aware of these differences, as your site could look dam ugly if you use the wrong font.


The font you choose is ultimately up to you. As long as it's a safe font you will be fine. However you should be aware of these rendering issues. One font you should probably not use is Lucida Grande/Sans. It renders awful in IE. Take a look at its rendering in Safari(Mac):


Looks nice doesn't it? Too bad it looks like this in Internet Explorer(PC):


Some people have stated that Lucida Sans will look fine in IE with ClearType, and others have said that it still looks bad. A smart alternative is to just not use Lucida Sans as your 'fallback font', and instead use Arial or another san-serif font.

Font Sizing

The ability to resize text differs amongst browsers and OS's. IE won't resize text thats set in pixels. If we set all text in em's, IE will exaggerate the text sizes when resized.


The best reference for font sizing is the article How to Size Type in CSS by Richard Rutter. The results - You need to specify the size as a percentage in the body element, and then size it in em's through the rest of the sheet. For line height, you need to define it in em's, rather than pixels, for consistent rendering.
One thing to remember is that the default font size is 16px. So to resize our type to 12px we use:

body {
   font-size: 75%;
   line-height: 1.5em;

Now you can size your type in em's like so:

   font-size: 3em;

Another suggested technique is to resize it down to 10px, which makes it easier to size upwards in em's. For example.

body {
     font-size: 62.5%;
     line-height: 1.5em;
h1 {
      font-size: 1.8em; /* 18px */
p {
      font-size: 1.2em; /* 12px */

here is an issue with this however, if people use small font option in Internet Explorer, it could be so small that it's unreadable. It's only a small chance. But worth noting.

Double Margins on Floats

We create CSS layouts by floating div's up against each other, like some form of horizontal tetris. When it reaches the end of a row, it drops down to the next. The common method for creating a grid is this:

#content {
     width: 300px;
     margin-right: 10px;
#sidebar {
     width: 100px;

This is what it should look like in a browser:


This is what IE does to it:


The margin width is doubled. Any margin that is on the same side as the float will be doubled. Don't ask why. It's just IE. This means the element on the left will have that margin stretched out to 20px, which will probably break the layout.


To fix it, all you need to do is put display:inline on your layout divs.

#content {
     width: 300px;
     margin-right: 10px;
#sidebar {
     width: 100px;

Now that margin bug is all fixed. Even though it only effects margins on the same side as the float, it can still be useful to include this fix. You never know when you might use a margin on the float side. It won't effect any other browser, so you can use it safely.

Expanding Box

The expanding box problem is a big issue with many css layouts. When you have a standard layout, with floats sitting next to each other, with set widths, but an image or long string of text is longer than this width, the layout will break in IE6. Take a look at this example:

#content {
     width: 300px;
     margin-right: 10px;
#sidebar {
     width: 100px;

This will render like in this most browsers:


However, in IE6, it will break like so:



The solution is to use the overflow property. If you place overflow:hidden; into the layout divs, the layout won't break in IE6.

#content {
     width: 300px;
     margin-right: 10px;
#sidebar {
     width: 100px;

This could, however, cause some issues with layouts depending on how complex they are. It also won't cause the text to wrap, and it will just remain hidden. It's unlikely you'll have a string long enough to break a layout, but it could happen. Another option is to use word-wrap: break-word; in an IE specific stylesheet. This won't effect images though, so you'll have to make a choice about with method is appropriate for your situation.

Clearing Floats

What we mean when we talk about clearing floats, is when a container or wrapper div doesn't correctly wrap around the containing divs. Take a look at this example:


See how the container is correctly containing the div's? This is what should happen. However, sometimes it does not clear correctly, like so:


The container isn't correctly wrapping around it. You probably won't notice this until you try and put a background on your container.


There are a few different solutions for clearing. The best solution however, is a simple overflow:auto or overflow:hidden in your container

#container {
     width: 966px;
     margin: 0 auto;

You need to keep in mind that overflow:auto might cause some issues in Firefox. If you do have any issues, use overflow:hidden instead. If this is still causing issues, take a look at some other forms of clearing floats. Apart from just adding this, you'll need to make sure hasLayout is triggered in IE6. You can do this by specifying a width or height. If you don't have a width in your container, you can use height:1% to trigger it, or zoom:1; if you can't afford to give it a height.

CSS Selectors

Although we would like to use all the brand spanking new CSS3 selectors, IE6 doesn't support all of the major ones. There are also still some CSS2 child and sibling selectors you simply shouldn't use if you want to support IE6:

  • E > F
  • E + F
  • E ~ F
  • :root
  • :last-child
  • :only-child
  • :nth-child()
  • :nth-last-child()
  • :first-of-type
  • :last-of-type
  • :only-of-type
  • :nth-of-type()
  • :nth-last-of-type()
  • :empty
  • :not()
  • :target
  • :enable
  • :disabled
  • :checked
  • Any of the E[attribute] Selectors
  • :first-child
  • :lang()
  • :before
  • ::before
  • :after
  • ::after

f course, a lot of these selectors aren't supported by even Firefox 3. For a full list of supported selectors, check out's post on browser css selector support


Stick to your standard selectors. Nothing fancy. Only use E + F, E > F, E ~ F when it won't make a huge difference in IE. If you really need to use these selectors, you should look at using IE8.js which gives IE6 better selector support. However this will slow down your site. But we don't really care about IE6 users do we?

PNG Transparency

IE6 doesn't support alpha transparency in PNG's. This is possibly the most annoying bug/issue with IE.


There are a few solutions for this problem. You can either use AlphaImageLoader in an IE specific stylesheet, link to a behaviour file in an IE specific stylesheet or use JS to fix the issue. Not matter which way you choose, there is no way to have transparent repeating background images.
To use AlphaImageLoader, it's a little bit tricky. Add these properties to any png image you want to have transparency. (You need to put this code in an IE specific stylesheet if you want your CSS to validate)

.trans {
     background-image: none;
     filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/transparent.png', sizingMethod='image/scale/crop');

Let's say you've given all your png image tags a class "trans", you select them with your css and use the filter property. You need to create a 1x1 transparent png file and link to it in the src attribute.

An even better way to do this is via a behaviour. It's similar to the AlphaImageLoader, except that you link to a behaviour script that triggers the transparency.

The third method is to use IE8.js which I mentioned earlier. It's even safer than the previous method, and you are very unlikely to run into any problems. Link to the script in your HTML, and it will make any png ending in -trans alpha-capable. eg. myimage-trans.png.

With all this methods, you need to be aware that you might still run into problems with transparent pngs. Make sure you test it in IE6 extensively