Skip to main content
ScotlandComputer ScienceSyllabus dot point

How does JavaScript add interactivity, and how are media files used on web pages?

JavaScript and media: adding interactivity with event-driven JavaScript (such as onmouseover, onmouseout and onclick), and using media files with appropriate standard file formats and compression, then testing and evaluating the website.

An SQA National 5 Computing Science answer on JavaScript and media, covering how event-driven JavaScript adds interactivity using events such as onmouseover, onmouseout and onclick, how media files (graphics, audio and video) use standard file formats and compression to manage file size, and how a website is tested and evaluated.

Generated by Claude Opus 4.810 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this key area is asking
  2. Event-driven JavaScript
  3. Media files: formats and compression
  4. Testing and evaluating the website
  5. Why this key area matters
  6. How this key area is examined
  7. For the official course specification

What this key area is asking

The SQA wants you to understand how event-driven JavaScript adds interactivity to a web page, how media files use standard file formats and compression to manage their size, and how a website is tested and evaluated.

Event-driven JavaScript

This is a different model from the top-to-bottom programs of Software design and development. A web page sits and waits; when the user does something, the matching event fires and its JavaScript runs. This is what makes pages respond to the user.

These events are attached to elements on the page, and each runs a piece of JavaScript when it happens. A classic example is a "rollover": onmouseover swaps an image for a highlighted version, and onmouseout swaps it back.

Media files: formats and compression

Using a standard format means the file will work in web browsers; using compression keeps the file small. The key idea examined is the link between compression and file size, and the benefits that follow.

Testing and evaluating the website

Once the pages, links, JavaScript and media are in place, the site is tested against its functional requirements: do the links work, do the events behave correctly, do the media files load, and does the site look right across pages? It is then evaluated for fitness for purpose - whether it does everything the requirements asked for - just as software and databases are evaluated.

Why this key area matters

JavaScript events turn a static page into an interactive one, responding to what the user does. Sensible use of media formats and compression keeps the site fast and efficient. Testing and evaluation confirm the finished site meets its purpose. Together these complete the web development process from design through to a working, tested site.

How this key area is examined

Questions ask you to describe event-driven programming and name events such as onclick, onmouseover and onmouseout, or explain why media files are compressed and the benefits of smaller files. Match each event to its action, and link compression to a smaller file size and then to faster loading and lower storage and bandwidth use.

For the official course specification

The SQA publishes the full National 5 Computing Science course specification, specimen question papers and coursework tasks at sqa.org.uk. Always revise from the current specification and SQA past papers, because question style and terminology are board-specific.

Exam-style practice questions

Practice questions written in the style of SQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

SQA N5 style3 marksDescribe what is meant by event-driven programming, and name two events that JavaScript can respond to on a web page.
Show worked answer →

One mark for the description and one for each of two events.

Event-driven programming means the code runs in response to events - actions by the user or the browser - rather than in a fixed order from top to bottom. The program waits for an event and then runs the code attached to it.

Two events JavaScript can respond to: onclick (the user clicks an element) and onmouseover (the pointer moves over an element). onmouseout is also acceptable.

Markers reward the idea that code runs in response to events, plus two genuine events such as onclick, onmouseover or onmouseout.

SQA N5 style3 marksExplain why media files such as photographs and videos are often compressed before being put on a website.
Show worked answer →

Three marks for linked points about file size, loading and storage.

Media files such as photographs and videos are large, so they are compressed to reduce their file size.

Smaller files download and load faster, especially on slow connections, improving the visitor's experience.

They also use less storage and less bandwidth. A good answer links compression to a smaller file size and then to faster loading and lower storage/bandwidth use.

Markers reward the chain: compression reduces file size, which makes pages load faster and saves storage and bandwidth.

Related dot points

Sources & how we know this