Fix remove unused javascript that are coming from youtube video like base.js etc

New Member
1 0 0


I want to remove the unused javascript that is coming from youtube. Please check screenshot below. It's just a simple technique to remove this but I can't find how to fix this. I have already added lazyload to youtube video. Please help me to fix this. I will be very thankful to all of you 



Shopify Partner
105 9 56

Hi @khurram123 

Since your scripts are coming from, it's not possible to only remove the unused code in this situation. You'd need direct access to their code.

The code is being delivered by a 3rd party source. In this case, it's Youtube. Even if you lazyload your videos, they will still require the necessary scripts (base.js, etc.) to load your videos.

So, unfortunately, it's not possible to alter the code coming from Youtube beyond removing your videos entirely.

Developer at SpeedBoostr (Shopify optimization and dev agency).
Try out our Shopify Analyzer (free performance analysis tool).
Check out Order Automator (app that auto tags + fulfills orders, and more automation)
More Apps: Theme Scientist (A/B testing tool), Tip Jar (add a tip button to your store), File Optimizer (optimize CSS, JS, Liquid)
Shopify Partner
127 13 77

JohnCodes is right in that you can't edit third party code to make it more effecient, simply not possible.

However, in the case of youtube and vimeo videos, you can apply the Facade method to not load the actual iframe and it's corosponding javascript code untill a user clicks on a placeholder image. Lazyload also will delay loading all that javascript, BUT, in your case i'm guessing the video is to close to the top of the page and thus is being loaded right away.

If you want to autoplay the video, then there's nothing to be done. 

Available for freelance. I specialize in speed improvement and theme development.