# Smooth image loading by upscaling

DevFeed: [Smooth image loading by upscaling](<https://devfeed.tech/articles/smooth-image-loading-by-upscaling-2141.md>)

Original publisher: [Read original article](<https://developers.soundcloud.com/blog//smooth-image-loading-by-upscaling>)

Published: 2014-02-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [SoundCloud Backstage](<https://devfeed.tech/sources/soundcloud-backstage-blog.md>)

Topics: [Image](<https://devfeed.tech/topics/image.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [Single-page application (SPA)](<https://devfeed.tech/topics/spa.md>), [Web app](<https://devfeed.tech/topics/webapp.md>)

Tags: [2](<https://devfeed.tech/tags/2.md>), [3](<https://devfeed.tech/tags/3.md>), [also](<https://devfeed.tech/tags/also.md>), [application](<https://devfeed.tech/tags/application.md>), [applications](<https://devfeed.tech/tags/applications.md>), [array](<https://devfeed.tech/tags/array.md>), [avatar](<https://devfeed.tech/tags/avatar.md>), [basic](<https://devfeed.tech/tags/basic.md>), [bind](<https://devfeed.tech/tags/bind.md>), [browser](<https://devfeed.tech/tags/browser.md>), [but](<https://devfeed.tech/tags/but.md>), [cache](<https://devfeed.tech/tags/cache.md>), [displays](<https://devfeed.tech/tags/displays.md>), [image](<https://devfeed.tech/tags/image.md>), [images](<https://devfeed.tech/tags/images.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [loading](<https://devfeed.tech/tags/loading.md>), [make](<https://devfeed.tech/tags/make.md>), [single-page-application](<https://devfeed.tech/tags/single-page-application.md>), [upscaling](<https://devfeed.tech/tags/upscaling.md>), [users](<https://devfeed.tech/tags/users.md>)

## AI overview

SoundCloud's image-loading technique uses a previously cached smaller image as a stretched placeholder while the requested larger image loads, then fades the larger image in. To avoid an extra HTTP request just for a brief placeholder, the code records which sizes have loaded during the session: it extracts an image identifier and size from each URL and stores size flags in an integer bitmask. When a larger image is requested, it selects the largest smaller cached size, or loads the full-size image normally if none is available. The excerpt reports a 30% memory difference between boolean arrays and integer bitmasks in one 10,000-image example, and notes that compact keys matter because keys consume much of the map's memory. Positioning and some implementation details are omitted.

## Source excerpt

The site is a single-page application that displays a multitude of users' images. At SoundCloud, we use a technique to make the loading of...