Author: Bill Ross | Reading Time: 4 minutes | Published: April 15, 2026 | Updated: April 15, 2026 WP Rocket is the most popular premium WordPress performance plugin and can resolve many PageSpeed issues automatically – without touching any code. It is a great starting point before making manual changes to your functions.php file. What WP Rocket handles automatically: How to install: Purchase WP Rocket from wp-rocket.me, upload the plugin zip via WordPress Admin → Plugins → Add New → Upload Plugin, activate it, and run your PageSpeed audit again. Many failed checks will resolve automatically. Note: If you install WP Rocket, check which issues it resolves before adding manual code to your functions.php – avoid duplicating fixes, as this can cause conflicts. You can add this to the prompt for defining the fix ( for example, include, I am using the WP Rocket plugin) – this will help it not only output the best Functions.php file, but also give you options to better utilize WP Rocket. Go to pagespeed.web.dev, enter your website URL, and click Analyze. Google will test both the mobile and desktop versions of your page and return a score from 0–100 across four categories: What to aim for: A Performance score of 95+ on desktop and 80+ on mobile. Anything below 60 is considered poor and needs urgent attention. Scroll down past your score to the Opportunities and Diagnostics sections. This lists every failed or underperforming check on your page. Note each one – these are what you will be fixing. Common failures on WordPress sites include: For each failed check, copy the name and description from PageSpeed Insights and paste it into Claude. Ask Claude to generate the appropriate functions.php code to resolve that specific issue in WordPress. Example prompt you can use:
“My WordPress site is failing the following PageSpeed Insights check. I am using the [Hub / Ave] theme with Visual Composer. Please generate the functions.php code for my WordPress child theme to fix this issue. Failed check: Eliminate render-blocking resources Description from PageSpeed Insights: Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles. Potential savings of 1,320 ms. The following resources have a significant blocking time: https://yourdomain.com/wp-content/themes/hub/css/style.css https://yourdomain.com/wp-includes/js/jquery/jquery.min.js
Include as much detail from the PageSpeed report as possible – the check name, the description, the estimated saving, and any specific files or URLs it lists. The more detail you provide, the more targeted and accurate the generated code will be. You can fix issues one at a time or batch multiple failures into a single prompt. Claude will output a ready-to-use code block you can copy directly into your child theme. Tips for better results: Before making any changes to your live file, open your current functions.php and copy the entire contents. Then go back to Claude and paste it in alongside the new code it just generated, with the following prompt:
“Here is my current functions.php file: [paste your existing functions.php contents here] Please combine this with the new code you just generated into a single, clean functions.php file, making sure there are no duplicate functions, no conflicts, and the formatting is consistent throughout.”
Claude will output a single merged file ready to copy and paste. This is the safest approach – combining the files first means you are replacing your existing file with one complete, reviewed version rather than manually inserting code snippets in the right places. Why this matters: Pasting new code into the wrong position in an existing functions.php file – for example, after a closing ?> tag or inside an existing function – is one of the most common causes of WordPress errors. Letting Claude merge and check the file eliminates that risk. Once Claude outputs the code, add it to the functions.php file in your child theme. Always edit the child theme – never the parent theme, as updates will overwrite your changes. How to access your functions.php file: ⚠️ Important – Back Up Before Editing: Always create a full backup of your website before modifying any theme files. A syntax error in functions.php can take your site offline. If that happens, access your file via FTP and remove or correct the added code. Paste the code Claude generated at the bottom of your functions.php file, above the closing ?> tag if one exists (most modern files do not have one). After each change, thoroughly test your website before running another PageSpeed audit. Performance changes – especially JavaScript deferral – can sometimes break interactive elements, page builder layouts, or third-party plugins. Testing checklist: If something breaks, return to Claude and paste a description of what is broken – Claude can update the code to exclude specific scripts or adjust the approach. Once your testing passes, go back to pagespeed.web.dev, re-run the analysis, and confirm your score has improved. Then repeat Steps 2–5 for each remaining failed item until you have worked through the full audit list. Note on image optimization: Some improvements – such as converting images to WebP format – cannot be handled through functions.php alone. For image conversion, use a plugin such as Imagify (it works well with the WP Rocket plugin) alongside your code changes. This guide is intended as a practical starting point. Every WordPress site is different – your theme, plugins, and hosting environment will all affect which fixes apply and how much improvement you achieve. Work through the audit methodically and test after every change. A Basic Guide To Use Claude.ai To Improve Page Speed for Your WordPress Website

Why Page Speed Matters
Optional Plugin: WP Rocket
Quick List of Steps – If You Know What You’re Doing
The Detailed Step-by-Step Guide
Step 1 – Run Your Audit on PageSpeed Insights
Step 2 – Identify All Failed Sections
Step 3 – Send Each Failed Section to Claude for a Fix
Step 4 – Combine the New Code with Your Existing functions.php
Step 5 – Update Your Child Theme’s functions.php File
Step 6 – Test All Website Functionality
Step 7 – Re-Run PageSpeed Insights and Repeat
- Our Story
- What We Do
Website Optimization
What's Your Situation
- What We’ve Done
- Resource Center
- Let’s Talk!