SaaS Webflow Template - Hudson- Created by Wedoflow.com and Azwedo.com
Back to Resource Cemter

Loading Third-Party Embeds: Best Practices

October 6, 2021

Loading third-party embeds is a common practice on many websites. Embeds can be used to provide an engaging user experience while loading content from another provider and delegating some sections of the web page to that provider. The most common examples of embeds are using video players, social-media feeds, maps, and advertisements. This article discusses loading best practices you can use when loading third parties such as efficient loading techniques and the Layout Shift Terminator tool which helps reduce layout shifts for popular embeds.

If you're using an embed code to share a video, make sure the embed is set to "no controls"

This option hides the video controller (play, pause, etc.) and is recommended by most providers. If you're using an embed code to share a social-media feed like Twitter or Facebook, avoid loading the provider's JavaScript library every time your page loads with each embedded tweet or post. Instead of loading their JS library multiple times, loading it once and storing the value in a variable will improve loading time.

Make sure your embedded images are at least 700px wide and don't exceed 1200px in height.

If you're loading images with an embed code, make sure the image is at least 700px wide and doesn't exceed 1200px in height. This ensures that users on smaller devices don't have to scroll horizontally or vertically when loading your content. Use iframes whenever possible because they help avoid the Layout Shift Terminator (LST) issue.


Iframes help avoid the Layout Shift Terminator (LST) issue, which occurs when loading content in an iFrame. To reduce loading time and improve performance for third-party embeds, make sure to use efficient loading techniques like Lazy Loading or Inlining. These techniques delay loading until after page rendering is complete by loading resources as

Always use the same URL for all of your embedded content

Always use the same URL for all of your embedded content. If one link goes down, it should be easy to find another version of that content.

When sharing YouTube videos on Twitter, always post the YouTube link rather than just linking back to YouTube's homepage.

When sharing YouTube videos on Twitter, always post the link to the YouTube video instead of linking back to its homepage. This ensures that if your tweet is truncated or shared through an app like Buffer or IFTTT, it will still work. When loading third-party content in JavaScript, try using Lazy Loading where possible.

This technique delays loading until after page rendering which results in faster loading time and improved performance. If you're loading resources with AJAX, avoid making unnecessary requests for large files

If you are loading resources via AJAX (e.g., jQuery), make sure not to load any larger than necessary because they can impact site speed. For example, don't load a 50MB image just because someone clicked

Try not to use more than two third-party embeds per article

When loading multiple third-party embeds, try to keep it under two per article. This will help with loading times and give readers more opportunities to engage with your content. Don't use a "pjax" push state AJAX request if you're loading an embedded map on the same page.

AJAX requests do not work well with maps because of how they handle session history. To avoid this problem, don't load any embedded maps on pjax pages. If possible, always defer scripts until after your web page has finished loading so that users can experience faster initial render time.

If you are loading scripts via JavaScript (e.g., Google Analytics or social media widgets), make sure to wait until after the

If you want people who click on an embedded tweet or Facebook post link (rather than clicking through directly) then make sure they stay within the page by adding "&" after each URL

If you want people who click on an embedded tweet or Facebook post link to stay within the page, add "&" after each URL. For example: twitter.com/user?original_referer=page-url" target="_blank"… &tw_p=tweetbutton … will open your Twitter profile in a new window but keep readers on this page. This way you will be keeping people on your web page and can still track Twitter traffic.

Conclusion:

Here are the most important points you should take away from this article. Make sure to use efficient loading techniques for third-party embeds, always defer scripts until after page rendering is complete, and if possible always load resources with an iFrame or Lazy Loading. Also, try not to exceed two embedded content per web page and keep loading paths consistent so that your audience can easily find what they're looking for. Don't forget about layout shifts caused by popular embedded content. For more information or help, feel free to contact us!

Other Posts

Will AI take over web development

The Top 10 Website Development Tips for 2023

2023 Consumer Trends Report

Let’s get to work

Interested in working with us or just have questions? Schedule a meeting today to kickstart your project!