I want to delay scripts of the shopify apps

I want to delay scripts of the shopify apps

Dhruv444
Visitor
1 0 1

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?

Replies 5 (5)

Huptech-Web
Shopify Partner
1004 204 215

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

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required

Huptech-Web
Shopify Partner
1004 204 215

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.

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
furre
Visitor
2 0 0

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

 

furre_0-1730749963420.png

 

 

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>

Huptech-Web
Shopify Partner
1004 204 215

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.

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
furre
Visitor
2 0 0

Hello,

 

I followed your instructions as mentioned. See below snippet that we created with your code. But I don't see the script either.

 

furre_0-1730818967267.png