Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Choosing graphics, audio and video

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

45 minutes

Why is the page so slow?

You open a shop page on your phone. You wait. And wait. The page is slow.

The reason is often one huge photo. It is 12 MB, and the screen shows it very small.

Developers choose pictures, sounds and videos with care. Today you learn how.

Key words

WordWhat it meansExample
AssetA file your software uses, such as a picture, a sound, a video or a code library.logo.png
File typeThe format of a file. The ending of its name often shows it..jpg, .mp3
File sizeHow much space a file takes. We count in KB and MB.4 MB
CompressionMaking a file smaller.
LossyCompression that removes some detail and you cannot get it back. The file is much smaller.JPEG, MP3
LosslessCompression that keeps every detail. You can rebuild the original.PNG, ZIP
StreamingPlaying a sound or video while it downloads, so you do not wait for all of it.
MetadataFacts about a file, such as who made it, when and what it shows.date, author, size
BandwidthHow much data a connection can carry each second.10 MB per second

The cells students fill in are left blank in this preview.

Small and large: KB and MB

UnitAbout how bigExample
1 KB (kilobyte)A short text fileA page of plain text
1 MB (megabyte)1,000 KBOne web photo, or a minute of music
1 GB (gigabyte)1,000 MBA film, or a game update

The cells students fill in are left blank in this preview.

Quick check: compression

Have a go

Quick check: compression

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Common file types

AssetTypeGood forWatch out
GraphicJPEG (.jpg)Photos. Small files, lossyBlurry edges on text and logos
GraphicPNG (.png)Logos, icons, clear edges. LosslessLarge files for photos
GraphicSVG (.svg)Shapes and logos that scale to any sizeNot for photos
AudioMP3 (.mp3)Music. Small, lossySome detail is lost
AudioWAV (.wav)Short sound effects, full qualityVery large files
VideoMP4 (.mp4)Almost every device plays itNeeds careful encoding (see below)
CodeJavaScript library (.js)Ready-made code that adds a featureEvery library adds KB and has rules for how you may use it

The cells students fill in are left blank in this preview.

Audio and video: stream or not?

A long video is too big to download first. So we stream it. The player shows the start while the rest still arrives.

To encode means to change a recording into a file format and a size that suits the device. You encode a video once, then stream it.

You can also embed a video. This means you put a player on your page that plays a video stored somewhere else, such as YouTube.

Worked example: size and time

QuestionStepAnswer
50 photos, 4 MB each. How much space?4 MB times 50 = 200 MB200 MB
A 100 MB file on a connection of 10 MB per second. How long?100 MB divided by 10 MB per second10 seconds
The same file on 5 MB per second?100 divided by 520 seconds
Two files, 3 MB and 7 MB. Total?3 + 710 MB

The cells students fill in are left blank in this preview.

Ask six questions about every asset

data-callouts.important.label

What quality do users need? How much bandwidth do they have? How much storage is there? Which device will show it? Which file type does that device play? Is there metadata to keep, such as the author and who owns it?

The lesson goes on

4 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.