
Third Party
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-codeInstalls 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
asyncordeferattributes for non-critical third-party scripts - Establish early connections with
preconnectanddns-prefetchresource 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
strategyvalues 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- Virtual Lists1.6K
- Route Based1.6K
- Tree Shaking1.6K
- Prpl1.6K
- Static Import1.6K
- Hooks Pattern1.2K
- React Composition 20261.2K
- Presentational Container Pattern1.2K
- React Render Optimization1.1K
- React Data Fetching1.1K
- Compound Pattern1.1K
- Hoc Pattern1.1K
- Client Side Rendering1.1K
- Render Props Pattern1.1K
- React Server Components1K
- Progressive Hydration1K
- React Selective Hydration1K
- Server Side Rendering997
- Incremental Static Rendering979
- Static Rendering965
- Streaming Ssr938
- Js Performance Patterns706
- View Transitions699
- Vite Bundle Optimization683