
If you're here, chances are you've tested your blog on Google PageSpeed Insights and noticed it flagging "unused JavaScript" as an opportunity to improve your site's speed. Don't worry, it's a common issue, and I’ll walk you through fixing it in simple steps.
Why Does This Happen?
Unused JavaScript usually comes from scripts that aren’t needed on every page of your site.
For example, Blogger's built-in widget scripts load everywhere, even on pages where those widgets aren’t used. This bloats your site, and makes it slower.
Since website speed is a crucial ranking factor (thanks to Core Web Vitals), cleaning up unused scripts can help your site load faster and rank higher.
Removing Unused JavaScript from Blogger Widgets - bloggerwidgets.js
Blogger's widget scripts are essential for features like comment forms and contact forms. But if you're not using certain widgets, the associated scripts are just dead weight.
To disable it make sure you are not using any blogger gadget on your template like
Here’s how to disable the script:
Method One - Safe
1. Log in to your Blogger dashboard.
2. Go to Theme > Edit HTML.
3. Add this attribute ( b:js='false
' )to the <html>
tag on your template to look like <html b:js='false' .....>
4. Find and Replace these tags:
Method Two - Assured
1. Log in to your Blogger dashboard.
2. Go to Theme > Edit HTML.
3. Press Ctrl + F to search through your template.
4. Find and Replace these tags:
<head>
with <!--<head>-->
</head>
with <!--<head/><b:if cond='!data:blog.adsenseClientId'>--></head></b:if>
and
</body>
with <!--</body>--></body>
Note: This removes unused JavaScript, but widgets that rely on these scripts (like the reply button) might stop working. So, only do this if you’re sure!
Removing Unused Script from Adsense
To remove unused AdSense JavaScript, you can simply remove the AdSense code if your site isn’t displaying ads yet.
However, the best approach is to use lazy loading for AdSense, which loads the script only when needed, improving your site’s performance. Here’s a quick guide on how to implement lazy loading for AdSense
Being Selective with Third-Party Plugins
Third-party scripts can also create unused JavaScript. If you’re using external plugins, limit their scope by loading them only on pages where they’re needed. Avoid adding all third-party scripts directly into your template.
Final Thoughts on this
Speeding up your Blogger site isn’t hard, but it does take some trial and error. Start by targeting unused JavaScript from Blogger widgets and AdSense, and be mindful of third-party plugins.
If you're careful, you'll have a faster, more efficient blog that both users and search engines will love. Got questions? Let me know!
happy... mxm