third-party
Teaches strategies for mitigating third-party script performance impact. Use when third-party scripts like analytics, ads, or widgets are degrading your page load times or Core Web Vitals.
What this skill does
# Optimize loading third-parties ## Table of Contents - [When to Use](#when-to-use) - [Instructions](#instructions) - [Details](#details) - [Source](#source) ## 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 It would be hard to find a modern site that operates in silos. Most sites coexist and depend on several other sources on the web for data, functions, content, and much more. Any resource located on another domain and consumed by your site is a third-party (3P) resource for your site. Typical third-party resources that are included on sites include: - Embeds for maps, videos, social media, and chat services - Advertisements - Analytics components and tag managers - A/B testing and personalization scripts - Utility libraries that provide ready-to-use helper functions such as those used for data visualization or animations. - [reCAPTCHA](https://www.google.com/recaptcha/about/) or CAPTCHA for bot detection. You can use third-parties to integrate other features that add value to your content or to reduce some drudgery involved in building a site from scratch. As per the Web Almanac report for 2021, more than [94% of the pages](https://almanac.httparchive.org/en/2021/third-parties#prevalence) on the web use third-parties - [images and JavaScript](https://almanac.httparchive.org/en/2020/third-parties#content-types) forming the most significant contributors to third-party content. While third-party resources can enrich your site with valuable features, they can also slow it down if: - They cause additional round trips to the third-party domain for every required resource. - They make heavy usage of JavaScript (impacting download and execution time) or are bulky in size because of unoptimized images/videos. - Individual site owners cannot influence the implementation, and their behavior can be unpredictable. - They can block the rendering of other critical resources on the page and affect [Core Web Vitals](https://web.dev/vitals/) (CWV). Despite these issues, third-parties may be essential to your business. If you cannot do away with 3P's, the next best thing is to optimize them to reduce performance impact. ### Assessing the performance impact of 3P resources You can use a combination of techniques to find how third-party code is affecting your site. - The following Lighthouse audits help identify slow third-party scripts that affect CWV: - [Reduce the impact of third-party code](https://web.dev/third-party-summary/) for scripts that block the main thread. - [Reduce JavaScript execution time](https://web.dev/bootup-time/) for scripts that take long to execute - [Avoid enormous network payloads](https://web.dev/total-byte-weight/) for large scripts - Use the WebPageTest (WPT) waterfall chart to identify [third-party blocking scripts](https://nooshu.com/blog/2019/10/02/how-to-read-a-wpt-waterfall-chart/#third-party-blocking-javascript) or WPT side-by-side comparison to [measure the impact of 3rd party tags](https://andydavies.me/blog/2018/02/19/using-webpagetest-to-measure-the-impact-of-3rd-party-tags/). - Sites like [Bundlephobia](https://bundlephobia.com/) help to assess the cost of adding available npm packages to your bundles. You can also find size and dependencies included in any package using [npm package search](https://www.npmjs.com/package/). ### Optimization strategies Since third-party code is not under your control, you cannot optimize the libraries directly. This leaves you with two options. 1. **Replace or remove**: If the value provided by the third-party script is not proportional to its performance cost, consider removing it. You can also evaluate other alternatives that are lightweight but provide similar functionality. 2. **Optimize the loading sequence**: The loading process involves loading several first-party and third-party resources in the browser. To design an optimal loading strategy, you would need to consider the browser assigned priority for different resources, their position on the page, and the value of each resource for the web page. #### Load 3P scripts efficiently Following are the time-tested best practices that can reduce the performance impact of third-party resources when used correctly. #### Use async or defer to prevent scripts from blocking other content. **Applicable to:** Non-critical scripts (tag managers, analytics) JavaScript download and execution is synchronous by default and can block the HTML parser and DOM construction on the main thread. Use of [async](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async) or [defer](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-defer) attributes in the `<script>` element tells the browser to download scripts asynchronously. You can use these to download any script that is not necessary for the critical rendering path (e.g., the main UI component). - **`defer`**: the script is fetched in parallel as the parser executes, and script execution is delayed till the parsing is complete. Defer should be the default choice for delaying execution until after DOM construction. - **`async`**: the script is fetched in parallel while parsing but executed as soon as it is available when it blocks the parser. For module scripts with dependencies, the script and all its dependencies are executed in the defer queue. Use `async` for scripts that need to run earlier in the loading process. For example, you may want to execute specific analytics scripts early without missing any early page-load data. ```html <script src="https://example.com/deferthis.js" defer></script> <script src="https://example.com/asyncthis.js" async></script> ``` One caveat worth mentioning here is that async and defer lower the browser assigned priority of the resources causing it to load significantly later. A new feature for [priority hints](https://web.dev/priority-hints/) can help to work around this problem. #### Establish early connections to required origins using resource hints **Applicable to:** Critical scripts, fonts, CSS, images from third-party CDNs Connecting to third-party origins can be slow due to the DNS lookups, redirects, and multiple round trips that may be required for each third-party server. Resource hints dns-prefetch and preconnect help cut down the time needed for this setup by initiating the connections early in the life cycle. Including a [dns-prefetch](https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch) resource hint corresponding to a domain will perform the DNS lookup early, thus reducing the latency associated with dns lookups. You can pair this with [preconnect](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preconnect) for the most critical resources. The preconnect initiates a connection with the third-party domain by performing TCP round trips and handling TLS negotiations in addition to the DNS lookup. ```html <head> <link rel="preconnect" href="http://example.com" /> <link rel="dns-prefetch" href="http://example.com" /> </head> ``` Benefits of using resource hints are evident in this case study where Andy Davies discusses how using [preconnect helped reduce the loading time](https://andydavies.me/blog/2019/03/22/improving-perceived-performance-with-a-link-rel-equals-preconnect-http-header/) for the main product image by i
Related in Ads & Marketing
ads
IncludedMulti-platform paid advertising audit and optimization skill. Analyzes Google, Meta, YouTube, LinkedIn, TikTok, Microsoft, and Apple Ads. 250+ checks with scoring, parallel agents, industry templates, and AI creative generation.
banana
IncludedAI image generation Creative Director powered by Google Gemini Nano Banana models. Use this skill for ANY request involving image creation, editing, visual asset production, or creative direction. Triggers on: generate an image, create a photo, edit this picture, design a logo, make a banner, visual for my anything, and all /banana commands. Handles text-to-image, image editing, multi-turn creative sessions, batch workflows, and brand presets.
rpg-migration-analyzer
IncludedAnalyzes legacy RPG (Report Program Generator) programs from AS/400 and IBM i systems for migration to modern Java applications. Extracts business logic from RPG III/IV/ILE source code, identifies data structures (D-specs), file operations (F-specs), program dependencies (CALLB/CALLP), and converts RPG constructs to Java equivalents. Generates migration reports, complexity estimates, and Java implementation strategies with POJO classes, JPA entities, and service methods. Use when modernizing AS/400 or IBM i legacy systems, analyzing RPG source files (.rpg, .rpgle, .RPGLE), converting RPG to Java, mapping data specifications to Java classes, planning legacy system migration, or when user mentions RPG analysis, Report Program Generator, RPG III/IV/ILE, AS/400 modernization, IBM i migration, packed decimal conversion, or mainframe application rewrite.
brand-library-architect
IncludedBuild a complete brand library for a product — visual asset render pipeline, brand documentation set (BRAND, COPY, MANIFESTO, BIOS, FAQ, GLOSSARY, TONE, PRICING), open-source convention files (README, CONTRIBUTING, SECURITY, CODE_OF_CONDUCT), and a self-contained press kit. This skill should be used when the user asks to "build a brand library / brand kit / press kit / brand assets" for a product, "set up a brand library workflow," "create a positioning manifesto plus visual identity," or any combination of brand documentation + visual asset pipeline. Apply phase-by-phase or run end-to-end. Templates are product-agnostic and use {{TOKEN}} placeholders the skill prompts the user to fill.
writing-tech-post
IncludedAuthors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
blog-google
IncludedGoogle API integration for blog performance: PageSpeed Insights, CrUX Core Web Vitals with 25-week history, Search Console performance, URL Inspection, Indexing API, GA4 organic traffic, NLP entity analysis for E-E-A-T, YouTube video search for embedding, and Google Ads Keyword Planner. Progressive feature availability based on credential tier (API key, OAuth/service account, GA4, Ads). Shares config with claude-seo at ~/.config/claude-seo/google-api.json. Use when user says "google data", "page speed", "core web vitals", "search console", "indexation", "GA4", "keyword research", "nlp entities", "blog performance", "youtube search", "google api setup".