Home

How to "light embed" to improve performance?

%3CLINGO-SUB%20id%3D%22lingo-sub-127384%22%20slang%3D%22en-US%22%3EHow%20to%20%22light%20embed%22%20to%20improve%20performance%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127384%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%20font-size%3A%2012pt%3B%22%3E%3CFONT%20face%3D%22Calibri%22%3EThis%20is%20related%20to%20Stream%3A%20The%20embed%20code%20used%20to%20insert%20into%20a%20separate%20file%20is%20a%20very%20common%20approach%20to%20embed%20videos%20on%20other%20pages.%20But%20when%20many%20videos%20are%20embedded%20on%20a%20page%2C%20it%20causes%20a%20significant%20delay%20in%20page%20load%20times.%20This%20is%20an%20effect%20that%20is%20common%20with%20all%20streaming%20services%2C%20not%20just%20Stream.%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%20font-size%3A%2012pt%3B%22%3E%3CFONT%20face%3D%22Calibri%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%20font-size%3A%2012pt%3B%22%3E%3CFONT%20face%3D%22Calibri%22%3ECan%20you%20help%20me%20determine%20if%20there%20is%20a%20way%20to%20do%20a%20%22light%20embed%22%20where%20just%20the%20thumbnail%20loads%20initially%2C%20and%20not%20all%20of%20the%20overhead%20involved%20in%20the%20player%20queuing%20up%20the%20videos%3F%20Below%20is%20a%20link%20that%20apparently%20works%20for%20YouTube%20embeds.%20I've%20tried%20it%20on%20Stream%20and%20it%20doesn't%20seem%20to%20work.%20But%20I%20suspect%20that%20there%20might%20be%20a%20syntax%20that%20does%20work%20for%20Stream.%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%20font-size%3A%2012pt%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fna01.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%253A%252F%252Fvarvy.com%252Fpagespeed%252Fdefer-videos.html%26amp%3Bdata%3D02%257C01%257Cammert%2540microsoft.com%257C7eb0db335c6a4b740c0b08d52ac328fa%257C72f988bf86f141af91ab2d7cd011db47%257C1%257C0%257C636461941161242186%26amp%3Bsdata%3DMnctJMuQGvcAChB0LolfqDPFCi%252BMqIvh11P%252FvZoMPlU%253D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Calibri%22%3Ehttps%3A%2F%2Fvarvy.com%2Fpagespeed%2Fdefer-videos.html%3C%2FFONT%3E%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-127396%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20%22light%20embed%22%20to%20improve%20performance%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127396%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20Marc!%20Will%20test.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-127387%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20%22light%20embed%22%20to%20improve%20performance%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-127387%22%20slang%3D%22en-US%22%3E%3CP%3EStream%20embed%20already%20does%20something%20like%20this.%20When%20we%20load%20our%20iFrame%20we%20don%E2%80%99t%20load%20the%20video%20or%20player%20yet.%20We%20just%20get%20enough%20code%20in%20place%20to%20load%20the%20thumbnail%20for%20the%20video.%20When%20the%20user%20clicks%20play%20then%20it%20loads%20the%20player%20and%20starts%20fetching%20the%20video.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%26nbsp%3Bthe%20page%20does%20still%20need%20to%20load%20our%26nbsp%3B%20javascript%20and%20make%20calls%20to%20Stream%20to%20get%20the%20thumbnail%20and%20metadata%2C%20etc.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20article%20attached%20below%20fully%20defers%20the%20iFrame%20from%20loading%20until%20after%20the%20page%20loads.%3C%2FP%3E%0A%3CP%3EI%20tried%20it%20just%20now%20against%20both%20YouTube%20and%20Stream%20and%20was%20able%20to%20make%20it%20work%20just%20as%20described%20in%20the%20article.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20my%20quick%20testing%20HTML%20that%20works%20for%20a%20video%20in%20Stream%20and%20YouTube...%3C%2FP%3E%0A%3CPRE%3E%26lt%3Bhtml%26gt%3B%0A%26lt%3Bscript%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20function%20init()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20vidDefer%20%3D%20document.getElementsByTagName('iframe')%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20(var%20i%3D0%3B%20i%26lt%3BvidDefer.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(vidDefer%5Bi%5D.getAttribute('data-src'))%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20vidDefer%5Bi%5D.setAttribute('src'%2CvidDefer%5Bi%5D.getAttribute('data-src'))%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%7D%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20window.onload%20%3D%20init%3B%0A%26lt%3B%2Fscript%26gt%3B%0A%0A%26lt%3Bbody%26gt%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Biframe%20width%3D%22640%22%20height%3D%22360%22%20src%3D%22%22%20data-src%3D%22https%3A%2F%2Fmsit.microsoftstream.com%2Fembed%2Fvideo%2Fa97032ac-0781-4dfa-adae-dadd2cf666db%3Fautoplay%3Dfalse%26amp%3Bshowinfo%3Dtrue%22%20frameborder%3D%220%22%20allowfullscreen%20%26gt%3B%26lt%3B%2Fiframe%26gt%3B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%26lt%3Biframe%20width%3D%22560%22%20height%3D%22315%22%20src%3D%22%22%20data-src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2FjofNR_WkoCE%22%20frameborder%3D%220%22%20allowfullscreen%26gt%3B%26lt%3B%2Fiframe%26gt%3B%0A%0A%26lt%3B%2Fbody%26gt%3B%0A%26lt%3B%2Fhtml%26gt%3B%0A%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Highlighted
Amber Mertes
Microsoft

 

This is related to Stream: The embed code used to insert into a separate file is a very common approach to embed videos on other pages. But when many videos are embedded on a page, it causes a significant delay in page load times. This is an effect that is common with all streaming services, not just Stream.

 

Can you help me determine if there is a way to do a "light embed" where just the thumbnail loads initially, and not all of the overhead involved in the player queuing up the videos? Below is a link that apparently works for YouTube embeds. I've tried it on Stream and it doesn't seem to work. But I suspect that there might be a syntax that does work for Stream.

https://varvy.com/pagespeed/defer-videos.html

 

2 Replies

Stream embed already does something like this. When we load our iFrame we don’t load the video or player yet. We just get enough code in place to load the thumbnail for the video. When the user clicks play then it loads the player and starts fetching the video. 

 

However the page does still need to load our  javascript and make calls to Stream to get the thumbnail and metadata, etc.

 

The article attached below fully defers the iFrame from loading until after the page loads.

I tried it just now against both YouTube and Stream and was able to make it work just as described in the article. 

 

Here is my quick testing HTML that works for a video in Stream and YouTube...

<html>
<script>
               function init() {
               var vidDefer = document.getElementsByTagName('iframe');
               for (var i=0; i<vidDefer.length; i++) {
               if(vidDefer[i].getAttribute('data-src')) {
               vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src'));
               } } }
               window.onload = init;
</script>

<body>
               <iframe width="640" height="360" src="" data-src="https://msit.microsoftstream.com/embed/video/a97032ac-0781-4dfa-adae-dadd2cf666db?autoplay=false&showinfo=true" frameborder="0" allowfullscreen ></iframe>

               <iframe width="560" height="315" src="" data-src="https://www.youtube.com/embed/jofNR_WkoCE" frameborder="0" allowfullscreen></iframe>

</body>
</html>

Thank you Marc! Will test.

Related Conversations
Embedding a Microsoft Video into a Sharepoint Online Site
testio2 in SharePoint on
8 Replies
Embed code not working
anonymous-user in Archived on
8 Replies
A problem with the Zoom level of a Tab
Tavory in Discussions on
9 Replies
Timer interrupt experiment decreases performance
cjc2112 in Discussions on
1 Replies
Any update on the large memory footprint?
Joel Janke in Microsoft Teams AMA on
3 Replies