The mechanism is simple — render the image at a tiny resolution (say 16×10px), then scale it back up with CSS while setting image-rendering: pixelated to disable the browser's default smoothing. What you see are the original pixels blown up into visible squares.
For photos, a canvas is typically drawn small with drawImage and then the canvas itself is scaled up with CSS. The mosaic block size is controlled purely by how small the intermediate resolution is — smaller means chunkier blocks.
When to use
Use for censoring sensitive content, retro-game graphics, low-res loading previews (LQIP). If the goal is actually hiding information, use large enough blocks — a mild setting can be reversed.