01 The starting point: fast on desktop, slow on mobile.
molt.agency started the day with a Lighthouse score of 69 on mobile. The numbers said there was room: FCP at 3.8 s, LCP at 5.5 s and a TBT of 142 ms. The desktop score, on the other hand, was above 90. The gap was real and known.
Lighthouse's initial diagnosis pointed to three main culprits:
- The 56 KiB CSS blocked rendering for 1.200 ms because the DigitalOcean server has a slow TTFB without edge caching.
-
A script
gtag.jsloaded directly caused 142 ms of forced reflow blocking the main thread. - The hero image was a PNG (102 KiB) instead of an optimized WebP with adaptive sizes.
Besides performance, we were missing analytics with GDPR consent and campaign conversion tracking. We decided to tackle it all in a single day of engineering.
02 Step 1: GTM with Consent Mode v2 and GDPR banner.
Before measuring anything you have to ask for legal permission. We implemented Google Tag Manager (GTM-WRQB45W6) with Consent Mode v2 following the AEPD guidelines and the European privacy standard:
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments) }
// Consent Mode v2: defaults antes de cargar GTM
gtag('consent', 'default', {
ad_storage: consentido ? 'granted' : 'denied',
analytics_storage: consentido ? 'granted' : 'denied',
ad_user_data: consentido ? 'granted' : 'denied',
ad_personalization:consentido ? 'granted' : 'denied',
wait_for_update: 500
});
The consent state is persisted in localStorage with the key molt_consent. The banner appears in Spanish, English and Catalan, with symmetric Accept / Reject buttons and a link to the privacy policy.
03 Step 2: GA4 and Google Ads conversions without blocking the thread.
Instead of loading gtag.js directly from the HTML (which caused the 142 ms forced reflow), we configured everything centrally from the GTM container:
The conversion fires by pushing an event to the dataLayer when the form redirects with ?contacto=enviado. GTM picks it up and sends it to Google Ads and GA4 with no extra server code.
04 Step 3: Hero images in WebP with responsive srcset.
The hero image of the decorative vector was an uncompressed original PNG. We converted to WebP and generated three sizes for the srcset:
| Archive | PNG original | Optimized WebP |
|---|---|---|
| vector-01-640 | 51 KiB | 18 KiB (−65 %) |
| vector-01-960 | 102 KiB | 37 KiB (−64 %) |
| vector-01 (1920) | 245 KiB | 88 KiB (−64 %) |
Lighthouse kept identifying that image as the LCP element because it falls inside the initial viewport on mobile (Moto G Power). With loading="lazy" it is excluded from LCP on viewports where it isn't visible, but in this case the image is large enough to appear above the fold.
05 Step 4: Cloudflare CDN — the change that moved the needle.
The real bottleneck was the DigitalOcean server: without edge caching, the 56 KiB CSS took 1.200 ms to reach the browser. No code trick was going to solve it. The definitive solution was to put a content delivery network in front.
We chose Cloudflare on the free plan. With the CDN active, the CSS goes from 1,200 ms to ~200–300 ms served directly from the Madrid data center. The impact on First Contentful Paint and Largest Contentful Paint is immediate.
06 Step 5: DNS migration from DigitalOcean to Cloudflare with no service interruptions.
The domain was registered at OVH with the nameservers pointing to DigitalOcean. For Cloudflare to be the authoritative DNS, the NS records were changed in the registrar's panel:
| Layer | Before | After |
|---|---|---|
| Registrar | OVH (unchanged) | OVH (unchanged) |
| Nameservers | ns1/2/3.digitalocean.com | benedict / josephine.ns.cloudflare.com |
| DNS Zone | DigitalOcean | Cloudflare (proxy on) |
| Origin server | 137.184.199.231 | 137.184.199.231 (unchanged) |
Cloudflare imported the DNS records automatically, but the records for Resend y AWS SES were missing because they were configured in DigitalOcean, not in the original OVH zone. We added them manually before propagation finished to avoid transactional email outages.
07 Results: from 69 to 87 in a single day.
The score from Cloudflare's Observatory (which always goes through the CDN) reflects the real ceiling reached. All Core Web Vitals turned green on the reference emulated mobile profile:
08 What's left to reach 90+.
The only remaining obstacle is the 56 KiB CSS that is still render-blocking. We tried making it async with the usual trick of onload, but the Speed Index rose from 2.9 s to 4.9 s because of FOUC (Flash of Unstyled Content): Tailwind CSS generates positional classes that affect the visible layout before the full file loads.
The clean solution is inline Critical CSS: extract the above-the-fold CSS, inline it in the <head> and load the full CSS asynchronously. With Tailwind 4 and Vite this fits into the build pipeline.
- Inline Critical CSS with Critters integrated into the Vite build.
-
Cloudflare cache rules for
/dist/*with an explicit edge TTL of 1 year. - Verification of real conversions in Google Ads with advanced attribution.
- Confirmation of events in GA4 Realtime.
“Speed isn't a cosmetic patch added at the end: it's delivery architecture. A well-configured CDN solves more bottlenecks than weeks of JavaScript micro-optimizations.”