Mobile app version of vmapp.org
Login or Join
Phylliss782

: How much effort should I put in to optimizing (cutting up) images for the web? I often get designs from our artists which contain large complicated images that can be turned into a background-color,

@Phylliss782

Posted in: #DesignPrinciples #Images #WebsiteDesign #Workflow

I often get designs from our artists which contain large complicated images that can be turned into a background-color, some tiling, and overlaid smaller images. The problem is, doing this often takes quite a while and adds complexity to the html structure. How should I decide wether it is worth doing?

For example, the following is a button / mouseover:



All the buttons in an atlas take up a whopping 232kb*.

I can get this down to 40kb by using a background color and overlaying the following:


top gradient (horizontal)
bottom gradient (vertical)
text
photo
outline
glow for mouse over


But then instead of 1 html element the button would take up several. In addition, I would have to spend several more hours to cut everything out and do the html/css.

So, as a new web developer, are there any guidelines for when to split images up vs just using the whole thing? Based on size/difference, time taken, and additional DOM complexity added?

In this specific case, at least extracting the glow seems like an obvious decision, as it only adds one element and halves the number of images.

*I'm fairly new to web development from non-web programming and may be wrong, but 200+ kb seems massive for just some of the art assets.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Phylliss782

3 Comments

Sorted by latest first Latest Oldest Best

 

@Vandalay110

I think the example code in the jsfiddle above is overly complex in the HTML. Much of the effects that you're looking for can be achieved with class-based css on one element. This approach would allow you to use one (semantic) element and style it appropriately...

from what i can see, you could use one or maybe 2 elements with added css and css pseudo elements to acheieve almost the exact same thing.

see example i quickly created: codepen.io/peterSalvato/pen/kDvra
this is as close as i can get while at work w/o an image editor to create transparent images to place in the design. once you have transparent images to add to the button in place of the text (you'd place them in the css:pseudoElements where it says 'content'... here is some reading on pseudo elements: www.w3schools.com/css/css_pseudo_elements.asp
one added benefit of this approach is it allows the text in your button to be HTML text. This is good for both SEO and accessibility (screen readers and such)...

hope this helps.

10% popularity Vote Up Vote Down


 

@Turnbaugh909

Not sure I understand the issue.

... 23.6k using "high" jpg settings.



and using Sliding doors CSS......

jsFiddle demo

23k is certainly acceptable. It could probably be reduced further.

I realize that 10 buttons this size may total the 200k you mention. But without knowing the entire layout and site purpose it's difficult to determine if that's aceptable. For example, larger image downloads are more acceptable on e-commerce or entertainment-based sites.

10% popularity Vote Up Vote Down


 

@Ravi4787994

I would ask the designer to work with you to rethink the button in terms of code rather than exportable graphics. It is absolutely worth the effort to make the button graphics lighter (in size). To your point, there is a lot more that will load on the page: the remainder of the graphics, CSS, HTML, javascript, and who knows what else. Why waste space because of a careless design process.

The gradients and background color could all be done in CSS, making the button lighter on load and easier to update. It also means you have one style that can be applied (with tweaks as necessary) across a range of buttons without consistency concerns.

At the most you have two graphics:


The type and white line art (with a CSS color overlay on the latter prior to hover)
The photographic trash can


You could slim that down by using live type for the labels.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme