I checked with the team and unfortunately, right now you can't remove unused JS Scripts. We do have this on Duda's Idea Board, definitely give it an upvote!
We continuously release improvements to optimize page speed, some of our most recent improvements are reflected in the recently updated Google CrUX report which shows how websites perform across the Core Web Vitals metrics.
You can check out this video where our Core Web Vitals expert @Russ_Jeffery talks more about this report:
We’re keeping this idea open and will continue to update as more improvements are made.
It's worth noting, that if there are just a couple of unused JS lines, that is not the reason why a site is has a slow loading time, and I'd look at other potential impacts.
Thank you very much! I voted!
WARNING: highly opinionated comment below…
Page loading speed is only an arguably small part of what makes a website rank high. Quality and amount of authoritative content, links, backlinks and other factors will often have a much higher influence. For example, in this 2022 study of the top 3 million high-ranking pages in Google, it was found that NONE of the pages achieved a 'Good' LCP score.
Then, we need to remind ourselves that ranking high in Google will not necessarily make your site successful. Google is an evil company whose business model is to collect private data on you and everyone that visits your site, and sell it. Thankfully, it has been steadily loosing market share. The most important point to keep in mind, however, is that a successful site is a site that helps the site owner achieve their business goals: more client engagement, more contact with prospectives, more sales. A 'higher search rank' may help you get there, but there are many other things you can do for their site that will have an even bigger impact. This latest study compilation from Forbes, for example, shows that Design plays a much, much bigger role on how a site actually performs for a business — citing figures that show, for example, how a very large percentage of small business sites don't even have a call-to-action!
The Duda team does an excellent job at keeping our sites optimised and among the best performing few, requiring very little care from us. That is part of what made me decide to stop hand-coding websites from scratch after 20 years, and switch to Duda: it frees our time to dedicate to things that actually make a difference, like Design, quality of content, and business strategy.