How to Best Optimize Your Videos for the Web – A Quick Guide

Gilad David Maayan Hacker Noon profile picture

Modern web sites are composed of HTML, dynamic JavaScript components, photos, video, and different wealthy media. On most web sites, wealthy media accounts for most of web page load time and are the heaviest components the person wants to retrieve over their restricted bandwidth. 

Videos on the net are a double edged sword. On the one hand, they’ll make an internet site way more compelling and interesting for customers. On the different hand, they’ll create usability points, efficiency issues and safety considerations. 

In this text I’ll clarify a number of methods to optimize movies, to guarantee they contribute to the person expertise, with out harming it. I’ll cowl how to choose the proper video format for your web site and net utility, and several other ideas to enhance usability and efficiency for video content material.

Selecting Video File Formats for the Web

Video optimization begins with choosing the proper format. There are many video formats on the market, however many will not be appropriate for use on the net, due to efficiency points, person expertise, or safety considerations. 

Let’s evaluate just a few fashionable codecs which are appropriate for web sites, and perceive their execs, cons, and technical properties. Here are the important video codecs you need to think about using in your web site or net utility.

Progressive video file codecs:

  • H264/AVC – this format makes use of an mp4 container and H264/AVC encoding. The majority of browsers and techniques assist this format, together with functions developed for iOS and Android. 
  • H265/HEVC – this format makes use of an mp4 container and H265/HEVC encoding. H265/HEVC codecs obtain excessive compression effectivity, which is roughly 50% lighter than H264/AVC. However, H265/HEVC is supported solely by Apple units.
  • VP9 – this format was constructed by Google to present an open-supply and royalty-free format various to H265. VP9 can cut back video measurement with minimal blurriness, if in any respect. However, it helps solely Chrome and Android and it’s barely much less environment friendly than H265.
  • AV1 – this format makes use of mappings for each MKV and MP4 containers. AV1 is license-free and achieves larger or related compression effectivity compared to H265. 

Adaptive bitrate (ABR) file codecs:

  • HLS – is an ABR protocol developed by Apple. It is supported by Apple units, Safari, and iOS functions, and might be tailored for open supply. The protocol can break up each H264 and H265 into chunks which are served as mp4, however H264 yields considerably higher outcomes.   
  • MPEG-DASH – is a codec-agnostic ABR protocol. It helps many encoding sorts, together with VP9, AV1, H265, and H264. This format at the moment comes with much less assist than HLS, and is, due to this fact, much less really helpful for enterprise web sites and particularly eCommerce shops.

Other Video Optimization Tips for Websites and Web Applications 

Note that the following ideas are helpful in case you are internet hosting your personal video and streaming it immediately out of your net server. If you choose to host your video on a web based video platform (OVP) equivalent to YouTube or Vimeo, the platform will care for most of those points. 

Make Videos Usable

The most vital factor to keep in mind when optimizing on-line video is to present customers with a very good expertise. Here are just a few key factors to take into account for enhancing person engagement:

  • Resize video for cellular units – for those who resize web page content material for cellular units, you want to resize video content material as nicely. Prepare a number of variations of video information, tailored to the commonest display sizes utilized by your guests.
  • Do not autoplay – it isn’t a standard follow on the net not to autoplay video, as a result of it’s disruptive and annoying for customers. However, in some circumstances you might have considered trying to autoplay a silent, background video, giving customers the possibility to activate audio.
  • Support low-bandwidth customers – not everybody watches movies over excessive-pace broadband connections. Provide viewers with gradual connections the possibility to watch a extra compressed model of the file. You can do that dynamically with adaptive bitrate streaming protocols.
  • Don’t take over the display – movies ought to be a part of an internet site structure and mustn’t take over the structure. Users ought to have an possibility to develop the video if they need to.

Deliver Video Using HTML5

Today this can be very frequent to ship movies over HTML5, which permits you to serve video content material to your web site guests with out requiring a plugin. You’ll want to use an HTML5-supported format.

MP4 information are the hottest and are supported by all browsers, whereas Chrome, Firefox and Opera additionally assist different codecs equivalent to WebM and Ogg.

Here is how to embed an HTML5 video into an internet web page, offering two variations of the file, WebM and MP4:

Here are attributes you need to use as a part of the

  • controls

    – defines whether or not play/pause button and quantity slider are displayed to the person

  • autoplay

    – if set to true, the video will begin taking part in as quickly as sufficient of it’s buffered

  • poster

    – preview picture for the video

You may use HTML5-enabled video gamers like Video.js or the Cloudinary video player.


You can use a content delivery network (CDN) to stream video content material and make it immediately out there to customers. Users haven’t got to wait for the video to be downloaded and buffered. CDNs are constructed into OVPs, however you can too use a CDN for movies you stream immediately out of your servers. 

CDN makes use of a wide range of caching methods to guarantee quick supply of media. Popular video content material is cached, and might then be shortly accessed by different customers in the identical location. The infrastructure and geographic protection offered by the CDN permits customers to entry video from any gadget and site, with out affecting video high quality or net web page efficiency.

Optimize Streaming Startup

When streaming video, a greatest follow is to begin with the lowest high quality stream to get the quickest playback pace. For lengthy movies, it is strongly recommended to use a medium high quality stream at the begin to ship a sharper end result and keep away from disappointing viewers.

When requesting a video stream, the server gives a manifest file in order that the participant can record all out there streams (together with measurement and bitrate info). In HLS streaming, the participant normally begins taking part in by choosing the first stream in the record.

You can leverage this by optimizing the first stream positioned in the manifest file, ensuring it runs optimally for the related gadget. You ought to present various manifest information for cellular and desktop units. 

You can enable customers to begin streaming sooner by offering a low high quality stream as the first stream in the manifest. Later on, as the consumer-facet participant higher understands the out there throughput, it’ll obtain further clips and might improve to the next-high quality stream. This means the person will initially see the video with some pixelation, after which it’ll develop into sharper. This can forestall a delay of 5-20 seconds that may occur in lots of streaming eventualities.


In this text I coated just a few video codecs that may present a very good expertise for web sites and net functions, together with progressive codecs like H264/AVC, H265/HEVC, and bitrate streaming protocols like HLS and MPEG-DASH.

In addition, I offered just a few ideas and tips for enhancing efficiency and person expertise for movies in your web site:

  • Ensure movies are cellular optimized and keep away from disrupting customers
  • Deliver video utilizing HTML5 to eradicate the want for plugins and compatibility points
  • Use CDN to enhance efficiency and cut back the load on net servers
  • For streaming bitrate codecs, optimize streaming startup to guarantee movies begin sooner

I hope it will assist you to enhance the supply of wealthy media information to your customers, enhance web page load time and create a greater person expertise.


Join Hacker Noon

Create your free account to unlock your customized studying expertise.

Recommended For You

Leave a Reply