I am creating an avatar creator for iPad. Users can select different hair styles, hair colours, skin colours etc.
The page has two components: A selection area (where the selected options are shown as small thumbnails) and a preview area (where the selected options are shown larger).
Each option is saved as a SVG file. Using SVG has a number of advantages:
- It remains sharp on Retina displays
- The file size of each asset is tiny (as the images are vector based)
- The files can be samll and still allow for transparency
- The same images can be used for the preview/selection area (The browser just scales them via CSS).
Jquery is used to change the class ids on the oage which in turn effects the CSS code that is called (the CSS holds the SVG images as background images).
There is a large number of options, so to avoid overwhelming the user only relevant options are shown in the selection area. For example, if you tap red hair, then only the red hair styles are shown (all the other hair styles are hidden until the user selects the relevant colour).
Everything works fine, the only draw back is that when the user taps on an option there is a delay while the browser goes to fetch the images from the server.
How can I speed up the loading process, so there is no delay?
Here are some options I have considered:
CSS Sprites Normally CSS sprite would fix this. However, because of the range of options, it isn't practical to create a CSS sprite by hand and none of the automated options support SVG sprite creation. If I switched to PNG, the file sizes would become very large.
Invisible Loading I have created a hidden DIV that has all my images stored as background images (Using the CSS3 multiple background image property). This ensures all the images are loaded so they are available for instant display when the users taps on them. The only drawback is that this causes the page to take a long time initially load.
Are there any better options?
(Unfortunately, I can't provide a link to my work).