All things Shopify and commerce
I have shopify website and i want to boost website speed. So for that i want to delay apps scripts as well. I already delay theme js but now can anyone let me know how to delay unwanted scripts?
Hi @Dhruv444
To delay or completely block the third party apps scripts ( not css ) you can use Yett Library
create a snippet & name it optimization or name you like and add below script
<script>
window.YETT_BLACKLIST = [/bars/,/gp/,/onsite/,/payment-sheet/,/shopify_chat/];
</script>
<script type="text/javascript" src="https://raw.githubusercontent.com/elbywan/yett/refs/heads/master/test/scripts/yett.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {$('body').one('mouseenter touchstart wheel', function() {window.yett.unblock('/gp/,/onsite/,/payment-sheet/,/cdn.judge.me/,/shopify_chat/');});});
</script>
Explanation
The code added in window.YETT_BLACKLIST 3rd party scrips url parts.
For example if check /onsite/ . So there is a script used for klaviyo app which is https://a.klaviyo.com/media/js/onsite/onsite.js so to block this I have taken a part from URL which is /onsite/. As YETT script work based on regex. so it will check the script's for specific part of it and then block it.
you can also use script name like this /onsite\.js/ in window.YETT_BLACKLIST array.
Other method
If you are able to access the js then you can add <script src="..." type="javascript/blocked"></script> to block it
window.yett.unblock is to use for unblocking the script once the store is loaded. To completely block it remove same reference from window.yett.unblock & it will blocked.
Thank you.
DP
Hi @Dhruv444
If the solution presented meets your needs and addresses your query effectively, I encourage you to accept it as the chosen answer. This will acknowledge your support and aid fellow community members in identifying reliable and effective solutions for their similar concerns.
Thank you.
Hello,
This didn't work for me. I created a snippet and added the below code for monster cart upsells app for our page here https://furre.pl/products/oczyszczacz-powietrza-dla-zwierzat and it didn't work
Want to delay this script here - https://cdn.shopify.com/extensions/ac65fde2-2227-41db-bb8f-d0fe3db1024a/monster-cart-upsell-free-gif...
window.YETT_BLACKLIST = [/monster-cart-upsell-free-gifts-286/];
</script>
<script type="text/javascript" src="https://raw.githubusercontent.com/elbywan/yett/refs/heads/master/test/scripts/yett.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {$('body').one('mouseenter touchstart wheel', function() {window.yett.unblock('/monster-cart-upsell-free-gifts-286/');});});
</script>
Hi @furre
I checked the URL https://furre.pl/products/oczyszczacz-powietrza-dla-zwierzat
But I didn't find the script YETT_BLACKLIST I suggested on this page.
Hello,
I followed your instructions as mentioned. See below snippet that we created with your code. But I don't see the script either.
The year-end shopping spree is around the corner! Is your online store ready for the ...
By JasonH Nov 10, 2024We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024