Types of Media
There are many different types of images, however we are going to focus on the three most common types of images you'll find around the web
Your most basic image type. These images tend to have very small file sizes, but they also don't have quite as many features as other image types.
These are pixel based images so they won't scale very well beyond their original size. They also don't support transparency, and so will block anything behind them in a rectangle with the dimensions of the image.
JPGs and JPEGs are the same type of image, however when embedding them in your page you will need to make sure you are using the correct file extension otherwise your site won't be able to locate the image
PNGs, like JPGs, are a pixel based image type, and as such do not scale well beyond their original size. However, unlike JPGs, PNGs suppport transparency, and as such can appear to be irregular shapes.
Despite how they appeare they are still rectangular and as such will prevent you from interacting with elements that are behind them even though you can see through them.
SVG stands for standard vector graphic and unlike other types of images they are not made out of pixels. They are instead collections of instructoins that tell the computer how to draw a specific shape.
Since they are not blocks of pixels SVGs can be scaled up indefinately with no detrinmental effects on quality. They also are exactly the shape they appear to be and as such will only block what they appear to cover.
Video is a popular part of many web apps, and can provide a hook to draw people into your age. There are several ways to get video (or video-like) content into your page.
- embedding the video directly
- embedding the video using an iFrame
You can also animate SVGs by applying transformations to them that are triggered under certain ocnditions
Video can be a great way to present information, or draw people into your site. There are two ways to embed a video file directly into your site both have benefits aand drawbacks.
By embedding a video directly into your site you can always make sure that your video is available. This is great for very small video files, but when working with larger video files it can slow your page's load time to a crawl, or even crash your site.
A better way to embed a (relatively) large video file would be to use an
<iframe> element. iframes open a window in your page to another site. This means that you can host your video on adedicated video platform (like YouTube) and then just reference that location in your iframe. This will prevent a video from slowing down your page's loading however the video may not be available immediately when the page loads. You will also need to make sure that you have the proper permissions to access your chosen vide hosting platform, and if the url path to that video changes it will break your iframe.
Animation with Canvas
You can animate elements within a
requestAnimationFrame functions. There are also canvas specific methods (such as
requestAnimationFrame()) that can be used to control animations.
There is a good tutorial for working with animations on MDN
You can include audio in your site using an
<audio> element with a
let myAudio = new Audio('filename.mp3') and setting it to play on some event. You can also open a window to a dedicated audio hosting platform like soundcloud using an
<iframe> element to speed up page load.