SlideShare a Scribd company logo
1 of 69
Download to read offline
HTML5, Flash and the Battle for
Faster Cat Videos
By YouTube's Greg Schechter and Phil Harnish
Greg Schechter             Phil Harnish
The Web Warrior        Sr. Play Button Eng




schechter@google.com   philharnish@google.com
HTML + JS + CSS + Awesomeness
HTML5



Offline File Access Multimedia Performance
       Presentation Graphics Storage
HTML5



Offline File Access Multimedia Performance
       Presentation Graphics Storage
Translation
HTML5 ~=


           By geishaboy500http://www.flickr.
           com/photos/geishaboy500/3183872667/
99% connected desktop penetration?
  http://www.adobe.com/products/player_census/flashplayer/
Why HTML5?
HTML5 vs Flash



Features Accessibility Device-ability
       Security Embeds API
Round 1: Features




   http://www.flickr.
   com/photos/zipckr/4624150058/
Why Flash?
Features missing in HTML5

● Content protection
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
● Fullscreen video
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
● Fullscreen video
   ○ Hardware accelerated HD cat videos!
   ○ **WebKit has a JavaScript API
Why Flash?
WebKit Fullscreen API




var elem = document.getElementById("my-element");
elem.onwebkitfullscreenchange = function() {
console.log ("We went fullscreen!");
};
elem.webkitRequestFullScreen();
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
● Fullscreen video
   ○ HD, hardware accelerated cat videos!
   ○ **WebKit has a JavaScript API
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
● Fullscreen video
   ○ HD, hardware accelerated cat videos!
   ○ **WebKit has a JavaScript API
● Consistent format support
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
● Fullscreen video
   ○ HD, hardware accelerated cat videos!
   ○ **WebKit has a JavaScript API
● Consistent format support
   ○ HTML5 needs to support both H.264 and WebM
Why Flash?
Features missing in HTML5

● Content protection
   ○ RTMPE protocol / Flash Access
● Camera & Microphone Access
● Fullscreen video
   ○ HD, hardware accelerated cat videos!
   ○ **WebKit has a JavaScript API
● Consistent format support
   ○ HTML5 needs to support both H.264 and WebM
● Cross platform consistency****
Why HTML5?
<video> Expectations

● Open source technology
   ○ Browser / Player / Codec
Why HTML5?
<video> Expectations

● Open source technology
   ○ Browser / Player / Codec
● Lower latency
   ○ No plug-in instantiation
Why HTML5?
<video> Expectations

● Open source technology
   ○ Browser / Player / Codec
● Lower latency
   ○ No plug-in instantiation
● Better performance and fidelity
Why HTML5?
<video> Expectations

● Open source technology
   ○ Browser / Player / Codec
● Lower latency
   ○ No plug-in instantiation
● Better performance and fidelity
● Accessibility
Why HTML5?
<video> Expectations




               http://imgs.xkcd.com/comics/in_ur_reality.png
Why HTML5?
<video> Expectations

● Open source technology
   ○ Browser / Player / Codec
● Lower latency
   ○ No plug-in instantiation
● Better performance and fidelity
● Accessibility
   ○ User agents can have special video handling
Round 2: Device-ability




By dakinyhttp://www.flickr.com/photos/dakiny/4430765149/
Why HTML5?
HTML5 Capable Browsers
Why HTML5?
Flash Support vs. HTML5 Support
Why HTML5?
YouTube Data API Usage for Flash vs. HTML5 Devices
Why HTML5?
When HTML5?
Primary Goal:
Recover playbacks that would
    be lost without flash
Our Solution
<iframe type="text/html"
 width="640"
 height="385"
 frameborder="0"
 src="http://www.youtube.com/embed/VIDEO_ID"
 allowfullscreen>
</iframe>
When HTML5?
<iframe> Embed

● Give the user HTML5 or Flash based on device and user
  preferences.
● Allows for better mobile support.
● Offers an "it just works" experience.
When HTML5?
When does the user get HTML5?
When HTML5?
  Detecting HTML5



var videoElement = document.createElement('video');
if (videoElement && videoElement.canPlayType &&
   (videoElement.canPlayType('video/mp4; codecs="avc1.42001E, mp4a.40.2"') ||
    videoElement.canPlayType('video/webm; codecs="vp8.0, vorbis"'))) {
  // Sweet, we can use HTML5!
}
When HTML5?
When does the user get HTML5?
Round 3: Performance




By Two Hawk's Eye
http://www.flickr.com/photos/mycoolpics/92033686/
Player Start Time
Flash

                   200ms
HTML5


 TODO(schechter): Add csi screen captures
iframe Embed Time Till Thumbnail Visible


Flash - 5.1s




HTML5 - 1.4s




           *Collected data shows faster load times than this control
           environment, but the comparison is actuate.
Get Video Time
Get Video Time


● HTML5:
   ○ Opera is Awesome
       ■ 200ms ahead of the pack
● Flash: IE9 and Opera are the leaders
   ○ 200ms faster
● HTML5 is almost always faster than Flash
   ○ 300ms - 350ms faster
   ○ IE9 is an exception
       ■ IE9 Flash is slightly faster than IE9 HTML5
Video Start Time

HTML5

Flash            2s
So why is flash so fast?
Make Assumptions
Making Assumptions
● Most users have a recent version of flash
● Thus we can optimistically embed the most
  common case and do version checking and
  updating after a script loads
● 250ms improvement to flash start time
Preload Video Connection
Preload Video Connection

 ● Resolves DNS while page is rendering
 ● Maintains an open connection
 ● 200ms improvement

<head>
 <script>
  var img = new Image();
  img.src = videoConnectionUrl;
 </script>
</head>
What about embeds?
#1 cache
1. youtube.com/v/di5I49yg7bY 302 redirect
2. s.ytimg.com/swf/l.swf?args&swf=swf2-hash_url.swf
3. s.ytimg.com/swf/swf2-hash_url.swf ~150kb
1. youtube.com/v/di5I49yg7bY 302
 2. s.ytimg.com/swf/l.swf?args&swf=swf2-hash_url.swf
 3. s.ytimg.com/swf/swf2-hash_url.swf

Better
 1. youtube.com/v/di5I49yg7bY application/x-shockwave-flash
 2. s.ytimg.com/swf/swf2-hash_url.swf
1. youtube.com/v/di5I49yg7bY 302
 2. s.ytimg.com/swf/l.swf?args&swf=swf2-hash_url.swf
 3. s.ytimg.com/swf/swf2-hash_url.swf


 1. youtube.com/v/di5I49yg7bY application/x-shockwave-flash
 2. s.ytimg.com/swf/swf2-hash_url.swf


Best
 1. youtube.com/embed/di5I49yg7bY text/html
 2. s.ytimg.com/swf/swf2-hash_url.swf
#2 lazy load
Most embeds are never played.
● Delay expensive queries.
● Use cache for most videos.
● Delay loading... flash?
Demo:
http://gregthebusker.com/iframedemo.html
Player API
http://code.google.com/apis/youtube/getting_started.html#player_apis
The JavaScript API
Communication
The JavaScript API
Communication

● Poll the URL fragment?
      http://youtube.com/embed/video_id#fragment
The JavaScript API
  Communication

  ● Poll the URL fragment?
http://youtube.com/embed/video_id#fragment
 ● Messages are one dimensional.
 ● Polling eats up CPU and is not instant.
 ● Both directions of communication use the same
   fragment.
The JavaScript API
 Communication

  ● Better idea: PostMessage API.
someWindow.postMessage(message, targetOrigin);
The JavaScript API
  Communication

  ● Better idea: PostMessage API.
someWindow.postMessage(message, targetOrigin);
  ● Uses JSON for native encoding and decoding of data.
  ● No polling.
  ● Native event listeners.
  ● Communications are sandboxed per-window.
  ● Calls are asynchronous.
Conclusion

● Flash is still preferred in most places
   ○ More critical features
   ○ Deeper reach

● HTML5 is awesome
   ○ Improves every day
   ○ Greater mobile reach
   ○ People want it
Questions?




          can haz question?
            By cloudzilla http://www.flickr.com/photos/cloudzilla/378829651/


schechter@google.com
philharnish@google.com

More Related Content

What's hot

Mobile Meow at Mobilism
Mobile Meow at MobilismMobile Meow at Mobilism
Mobile Meow at Mobilism
Greg Schechter
 
High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)
Nicholas Zakas
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
Simon Willison
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use Today
Todd Anglin
 
High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)
Nicholas Zakas
 

What's hot (20)

Mobile Meow at Mobilism
Mobile Meow at MobilismMobile Meow at Mobilism
Mobile Meow at Mobilism
 
Html5 vs Flash video
Html5 vs Flash videoHtml5 vs Flash video
Html5 vs Flash video
 
HTML5 Multimedia Accessibility
HTML5 Multimedia AccessibilityHTML5 Multimedia Accessibility
HTML5 Multimedia Accessibility
 
Mobile Web Speed Bumps
Mobile Web Speed BumpsMobile Web Speed Bumps
Mobile Web Speed Bumps
 
State of Media Accessibility in HTML5
State of Media Accessibility in HTML5State of Media Accessibility in HTML5
State of Media Accessibility in HTML5
 
[edUiconf] HTML5 does all that… and i can haz cheeseburger? You bet!
[edUiconf] HTML5 does all that… and i can haz cheeseburger? You bet![edUiconf] HTML5 does all that… and i can haz cheeseburger? You bet!
[edUiconf] HTML5 does all that… and i can haz cheeseburger? You bet!
 
Edge of the Web
Edge of the WebEdge of the Web
Edge of the Web
 
StoryCode Immersion #5 - Popcorn.JS Deep Dive
StoryCode Immersion #5 - Popcorn.JS Deep DiveStoryCode Immersion #5 - Popcorn.JS Deep Dive
StoryCode Immersion #5 - Popcorn.JS Deep Dive
 
Looking into HTML5 + CSS3
Looking into HTML5 + CSS3Looking into HTML5 + CSS3
Looking into HTML5 + CSS3
 
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
 
High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)High Performance JavaScript (CapitolJS 2011)
High Performance JavaScript (CapitolJS 2011)
 
HTML5 Multimedia: where we are, where we're going
HTML5 Multimedia: where we are, where we're goingHTML5 Multimedia: where we are, where we're going
HTML5 Multimedia: where we are, where we're going
 
Html5video
Html5videoHtml5video
Html5video
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
 
Developers meetup sep-2017
Developers meetup sep-2017Developers meetup sep-2017
Developers meetup sep-2017
 
The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5The Rich Standard: Getting Familiar with HTML5
The Rich Standard: Getting Familiar with HTML5
 
soft-shake.ch - Introduction to HTML5
soft-shake.ch - Introduction to HTML5soft-shake.ch - Introduction to HTML5
soft-shake.ch - Introduction to HTML5
 
HTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use TodayHTML5 and CSS3 Techniques You Can Use Today
HTML5 and CSS3 Techniques You Can Use Today
 
Html5 Video Vs Flash Video presentation
Html5 Video Vs Flash Video presentationHtml5 Video Vs Flash Video presentation
Html5 Video Vs Flash Video presentation
 
High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)High Performance JavaScript (Amazon DevCon 2011)
High Performance JavaScript (Amazon DevCon 2011)
 

Similar to HTML5, Flash, and the Battle For Faster Cat Videos

Similar to HTML5, Flash, and the Battle For Faster Cat Videos (20)

GDD HTML5, Flash, and the Battle for Faster Cat Videos
GDD HTML5, Flash, and the Battle for Faster Cat VideosGDD HTML5, Flash, and the Battle for Faster Cat Videos
GDD HTML5, Flash, and the Battle for Faster Cat Videos
 
Multimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioMultimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audio
 
Video Killed My Data Plan: Helsinki
Video Killed My Data Plan: HelsinkiVideo Killed My Data Plan: Helsinki
Video Killed My Data Plan: Helsinki
 
HTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're goingHTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're going
 
Video performance munichfrontend
Video performance munichfrontendVideo performance munichfrontend
Video performance munichfrontend
 
T3fest video
T3fest videoT3fest video
T3fest video
 
NodeJS Edinburgh Video Killed My Data Plan
NodeJS Edinburgh Video Killed My Data PlanNodeJS Edinburgh Video Killed My Data Plan
NodeJS Edinburgh Video Killed My Data Plan
 
Video performance snowcamp
Video performance snowcampVideo performance snowcamp
Video performance snowcamp
 
Video performance barcelona-js_coders
Video performance barcelona-js_codersVideo performance barcelona-js_coders
Video performance barcelona-js_coders
 
Frontcon video
Frontcon videoFrontcon video
Frontcon video
 
Video performance glasgow
Video performance glasgowVideo performance glasgow
Video performance glasgow
 
HTML5 video & Amazon elastic transcoder - FCIP August 2014
HTML5 video & Amazon elastic transcoder - FCIP August 2014HTML5 video & Amazon elastic transcoder - FCIP August 2014
HTML5 video & Amazon elastic transcoder - FCIP August 2014
 
Krakow video
Krakow videoKrakow video
Krakow video
 
Gdg lublin video
Gdg lublin videoGdg lublin video
Gdg lublin video
 
HTML5 Video
HTML5 VideoHTML5 Video
HTML5 Video
 
Rija js video
Rija js videoRija js video
Rija js video
 
IBC Content Everywhere Hub Presentation: HTML5 And Fastest Encoding
IBC Content Everywhere Hub Presentation: HTML5 And Fastest EncodingIBC Content Everywhere Hub Presentation: HTML5 And Fastest Encoding
IBC Content Everywhere Hub Presentation: HTML5 And Fastest Encoding
 
Portogdg video
Portogdg videoPortogdg video
Portogdg video
 
Warsawclouddays video
Warsawclouddays videoWarsawclouddays video
Warsawclouddays video
 
Vilnius py video
Vilnius py videoVilnius py video
Vilnius py video
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

HTML5, Flash, and the Battle For Faster Cat Videos