If third-party scripts are tanking your Core Web Vitals, this skill walks you through proven mitigation strategies. You'll learn when to use async versus defer attributes, how to set up early connections with preconnect and dns-prefetch, and how to lazy-load resource-heavy embeds like YouTube videos or social widgets using IntersectionObserver. It covers both the assessment side (using Lighthouse audits and WebPageTest waterfalls to identify blocking scripts) and the optimization side (self-hosting critical resources, using Next.js Script component strategies). The guidance comes from patterns.dev and focuses on keeping essential third-party functionality while minimizing the performance hit on analytics, ads, and chat widgets.

skills.sh installs
1.6K
GitHub stars
258
last updated
Aug 21, 2026

Install

$ npx -y skills add patternsdev/skills --skill third-party --agent claude-code

Installs into .claude/skills of the current project.

Files

Optimize loading third-parties

Table of Contents

When to Use

  • Use this when third-party scripts (analytics, ads, chat widgets, social embeds) are slowing down your site
  • This is helpful for optimizing Core Web Vitals while retaining essential third-party functionality

Instructions

  • Use async or defer attributes for non-critical third-party scripts
  • Establish early connections with preconnect and dns-prefetch resource hints
  • Lazy-load below-the-fold embeds (YouTube, maps, social media) using IntersectionObserver or facades
  • Consider self-hosting critical third-party scripts for better caching control
  • Use the Next.js Script component with appropriate strategy values for framework-level optimization

Details

Sponsors

Details

Repository
github.com/patternsdev/skills
Categories
Data Science & ML, Debugging, Automation & Workflows, Marketing & SEO
First seen
Jun 3, 2026

More from patternsdev/skills

All 47
1nvidia avatartao-run-on-kubernetesnvidia/skillsKubernetes execution platform — submits TAO container jobs as single-pod k8s Jobs with NVIDIA GPU scheduling. Use when running on EKS / GKE / AKS / on-prem clus1.6Kskills.sh installs
2ailabs-393 avatarstartup-validatorailabs-393/ai-labs-claude-skillsComprehensive startup idea validation and market analysis tool. Use when users need to evaluate a startup idea, assess market fit, analyze competition, validate1.6Kskills.sh installs
3nvidia avatartao-train-metric-learning-recognitionnvidia/skillsMetric-learning recognition (ml-recog) for fine-grained visual recognition. Learns embeddings for retrieval-based matching (e.g., retail product recognition) us1.6Kskills.sh installs
4nvidia avatartao-train-single-stepnvidia/skillsStandard single-step train/eval/export workflow for any TAO model. Use when training a TAO model on a dataset without iterative data augmentation, AutoML, or DE1.6Kskills.sh installs
5nvidia avatartao-run-automl-deft-pipelinenvidia/skillsRun the canonical NVIDIA AOI three-phase training pipeline — Phase 1 AutoML baseline (HPO), Phase 2 DEFT loop (RCA → SDG → mining → plain-train retrain), Phase 1.6Kskills.sh installs
6bahayonghang avatartypst-paperbahayonghang/academic-writing-skillsTypst paper assistant for existing .typ manuscripts in English or Chinese. Use for compile/export diagnosis, venue formatting, BibTeX/Hayagriva checks, grammar,1.6Kskills.sh installs