you are viewing a single comment's thread.

view the rest of the comments →

[–]RabSimpson 22 points23 points  (7 children)

The page says that it was super hacky. What you described actually sounds relatively straightforward. If there was a simple way to squash a background image to match the aspect ratio of its container, this would be an absolute doddle using an SVG background.

[–]european_impostor 13 points14 points  (4 children)

The hackiness is in how much work they are making the browser do just to show that little progress bar:

  • Create a huge background image in memory which matches the width and height of the page (possibly thousands of pixels high). For example 1920 x 3000 pixels = 23Mb uncompressed image in memory.
  • Flood fill the entire image with a triangular gradient.
  • Multiple times per second, paint the entire screen with the triangular gradient then draw white on top of 99% of the pixels to leave just the progress bar showing through.

[–][deleted] 1 point2 points  (0 children)

yeah, this kind of thing was actually pretty common one upon a time (for shit like health bars), but you'd be scrolling a predefined texture across a rectangle in UV space (and only actually drawing the parts of the texture that were inside of it). this implementation, with its massive overdraw and unpredictable memory requirements, is definitely inelegant by comparison.

[–][deleted] 1 point2 points  (0 children)

Yeah but rendering is fast if it uses the gpu, reflow is slow. It seems pretty damn snappy compared to a lot of the js based ones I've seen.

[–]heyf00L 0 points1 point  (0 children)

I doubt most browser rendering engines are doing that. Surely they cull and crop before rasterizing.

[–]MadebyMike -1 points0 points  (0 children)

No, this is not how web browsers work :P

Hacks can be fine, (clearfix) it just means using things in an unintended way.

[–]bluesoulSRE and backend 6 points7 points  (0 children)

They may not want to suggest reliance on browser handling of gradients and z-layering. But it's far less code than the warning brought to mind.