Web Performance 101
Video content engages users, and doesn't have to impact your page's performance. These techniques will ensure your video content is optimized.
Join the DZone community and get the full member experience.Join For Free
web page content is a mix of rich html, images, videos, and other media types. multimedia content can add significantly to the overall page size and directly affect web page performance. this doesn’t mean embedding videos is against best practices; all types of page content can be tuned to overcome any negative impact on performance. optimizing a web page is a critical step in ensuring a satisfactory digital experience, and this process is incomplete if the video content is overlooked.
video content boosts user experience and conversion rates. high-resolution videos are now a staple in web page design, and this translates to heavier web pages. there are a variety video formats available today with each format having its own set of specifications and limitations.
some of the common types of video files used in web pages include wmv, flv, mov, webm, and mp4. mp4 and webm are the most popular formats and is used across different video sharing platforms like youtube and vimeo as the video quality is better than other file types. another advantage of using mp4 and webm files is that the size is relatively smaller and it is supported by most browsers.
if you aim to deliver the best digital experience without compromising on rich multi-media content on your website, then there are two main aspects to consider:
- optimizing the video content to provide high-quality video with minimum impact to page speed.
- optimizing the page design to embed and display multi-media content and boost the user experience.
optimizing video content
videos don’t necessarily have to be an impediment to improved web page performance; there are several ways to tune the media content in a page to complement the page performance. here are some of how you can optimize video files:
the most basic step in optimizing video is cutting down the file size to make it easier to download and play. a video’s file size depends on the bit rate and other metadata attached to it. data compression is one of the techniques that can be used to reduce the video file size without losing the video quality. ffmpeg, handbrake, and mpegstreamclip are some of the compression tools available. these tools restructure the way the pixel data is stored to make the final video optimized and lighter.
file format– converting to html5 videos
the file format can also contribute to the video file size; different video file types store data in different ways which is why a webm video is lighter than an mp4 video. in addition to the bytes a video file adds to the page, we should also consider browser support; browsers may support only a few of the available formats and this makes it important to ensure you are not embedding videos on your page that requires extra plugins.
modern browsers support html 5 video formats like mp4, webm and ogg video. so, it is recommended to convert the videos to one of these formats to make it easier to optimize and embed n webpages.
cdns can be used to stream video content so that it is available to the user instantaneously; the user need not wait for the video to download and buffer. ovps or online video platform providers offer services that handles video optimization to provide the user with seamless video streaming.
cdn’s employ different caching techniques to ensure the requested media is delivered quickly and it is common practice for cdns to cache popular video content. the infrastructure and geographical coverage provided by cdns makes it possible for users to access videos from any device and from any location without compromising the video quality or webpage performance.
traditionally media files were downloaded or copied to the user’s system before playback; this usually resulted in latency and loss of quality. streaming was introduced to directly “stream” media content from a server to a media player on the browser.
several new technologies make use of adaptive bitrate streaming over http to enable streaming; some of these include mpeg-dash, http live streaming (hls), and http dynamic streaming (hds). all these protocols are designed to stream videos from a regular http server making specialized media delivery servers redundant. the video stream is broken into smaller chunks of different bitrates that are ready for playback; a device trying to view the video file can pick the data stream as needed based on the bandwidth available.
optimizing page design for video
in addition to the format and data delivery of the video content, it is also important to optimize the web page design so that it doesn’t hinder the user experience. here are some points to consider when designing your website:
optimizing for mobile devices
the video content on a page must be optimized for mobile devices as the display resolution and size vary across different mobile devices. the video must adjust along with the responsive design of the website; it should also detect the device orientation and display the video accordingly.
video size and placement
the size of the video embedded on the page is as important as the video format and file size. using html or css to specify the exact width and height of the embedded video allows the browser to allocate the required bandwidth and avoid unnecessary overhead.
embedded videos that are configured to auto-play requires the page to make additional requests for files and resources needed for video playback, this can slow down the page significantly. deferring videos from loading till after the initial page load has completed frees up bandwidth, allowing the page to load faster.
to embed or not to embed
website designs are more creative and fluid than ever. multimedia content has become a necessity in engaging users and can improve conversion rates on your website. it also provides a unique digital experience. so, there are more reasons to embed videos on your web page than there are disadvantages. there is no cost to performance if we optimize the page design, pick the right video format, and utilize media delivery providers to handle video processing efficiently.
Published at DZone with permission of Kameerath Abdul Kareem, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.