[picture web front-end optimization fuzzy to clear] to see how my QQ space displ

Preface

This article estimates will not be too long, risk removal home, but the old (called the old because we really leaves Xiaochai are over 100 years old) is not afraid to drop. So, I come.!

Digression: Today we still see a front end of the interview questions, then I had wanted to look for a few to do, but did not find anything, you have any good end interview questions please message to me Oh, we together to analyze interview questions and progress.!

The end time, I had a discussion with our products, is the image compression, because I to the picture or PS this is a small white, so I made a picture with 100 to K directly to go up, the result is our colleagues in a compression, we only have 50 K, the exchanges a little experience on the image compression, and for the second time to exchange the foreshadowing, second is clearly studied by fuzzy pictures.

Webpage picture format

Here I first on our picture format a universal right, reference:

[Finishing] about JPG, GIF and PNG of each type of picture format

GIF

Transparent type, can be transparent or opaque, translucent, such things don't find him, and this guy can do animation.

GIF is a lossless format picture

Gif LZW algorithm is used for compression, when the pixel compression GIF process from top to bottom compression, i.e. transverse GIF images than the longitudinal small (500*10 10*500)

The GIF can support a selective interval progressive display

JPEG

Does not support transparency.

Does not support animation.

The picture is very easy to loss

Support interlaced progressive display (ie does not support, ie will be the whole picture information arriving after the show)

Photography and digital photo album JEPG is especially suitable for web.

PNG

Support all kinds of transparent, but bug needs to use the filter processing in IE6

Does not support animation.

Any operation without loss of its quality

The support interval of progressive enhancement, but will cause picture size:

PNG8 (Boolean transparent)
Equivalent static GIF, only 256 colors, support index transparent, is to specify a pixel is not transparent

PNG8 (alpha)
Specify the pixel transparency, for example 50% transparency
Advantages of smaller than png24/32, the same effect, drawback for IE6 does not support

png24
Opaque colors, many more than 256 color, PS derived png24 actually is png32

png32
Like the PS inside the PSD, including layer and the channel information

The above is some information about the image, we probably know is, which I want to say one of the PNG, especially the staggered png

PNG interleavingIn the use of the browser to appreciate the picture will by fuzzy gradually clear effect gradually display out way. Interleaving method of PNG advanced, the image is horizontal and vertical style picture on the screen, faster download speeds, role: alternative to download time feels shorter, and the visitors that are downloaded. No cross, no PNG staggered no this function.

Picture display

We know that img tags are not loaded in DOM loading time, but in the DOM structure of all out and formed the render tree (layout end), to load.

The loading sequence is top-down loading, mean picture we see above to see below, but obviously this is not a good show, if we can start to see the fuzzy graph and then slowly become clear is it right? A lot better.?

Certainly a lot better. . .

Then we discuss how to realize, but when it comes to the staggered PNG, although I was the letter, because I do not quite understand, but to think but something doesn't feel right!

Users of the confusion

Now let's imagine QQ space approach (the pure GAB), I now as a user, I upload the picture to the

I want to QQ space as the cloud storage place, upload my 2M's graduation

The space to generate a thumbnail and a big picture according to the demand of

We first see a thumbnail, and then see the larger screen, click on the image to see my first time 2M photos

The above is I thought logic, QQ space is it right? This logic we don't pay attention to him, because stand in user angle, I must want to keep my first.

Well now, QQ space how do??? That is too complicated, we also do not pay attention to, I am here to say I do.

Realize image from fuzzy to clear

Our album showed that looks like this:

The above is a thumbnail, here is the map, we can actually do the thumbnail here!!!

We can use the thumbnail &ldquo before the map display; instead of ” large, to have a look our logic:

① the thumbnail in the photo above, the first loading, even in the bottom, because the thumbnail size is very small load very quickly

It will initially thumbnails in map display position, its size to large size (the size of a variety of methods can be obtained, such as upload when calculating end)

The graph layout in thumbnail thumbnail before, because have shown, but because too large and somewhat vague, but the big loading it from top to bottom slowly becomes clear to give a person a kind of fuzzy to clear.

The end of the process

So we to have a look at our QQ space, look before we use tools to speed, speed limit our Firefox:

PS: Limit open space giant slow. . .

What, is slow.!

Look at it from top to bottom change Oh, then I found out the evidence

PS: I opened the Internet restrictions still very slow, it is the reason why I slow speed. .

Please look at my side with three pieces of local red box around it:

The first container album display, relative positioning

Second small thumbnails for the above, a very small one.:

Look, here living will people pull so big. . . . .

The third frame is the protagonist, large.:

Conclusion

From the whole arrangement, and we thought, he did a good Oh, for instance we here the picture above navigation:

We see the thumbnails already demonstrated, a thumbnail display when you click next, won't appear blank fault, then enlarge slowly display so that users are willing to stop there.

Conclusion

Well, today we interview questions, and then studied the pictures from fuzzy to clear solution, if you have a better solution don't hide oh!

Well, if you have good web front-end interview questions please leave, I recently in the collation, behind will help you drop on, finally leaving a old photos.!

Posted by Conrad at November 21, 2013 - 9:41 AM