cdn-usage
Use when adding external browser dependencies via CDN - Provides CDN selection guidance to ensure reliable script loading.
When & Why to Use This Skill
This Claude skill provides expert guidance on selecting and implementing Content Delivery Networks (CDNs) for external browser dependencies. It optimizes web development workflows by recommending the most reliable CDN providers—such as jsDelivr, cdnjs, and esm.sh—while ensuring correct versioning and implementing robust error-handling patterns to prevent script loading failures.
Use Cases
- Scenario 1: Selecting the optimal CDN provider and syntax (UMD vs. ESM) when adding external libraries like Three.js or jQuery to a web project.
- Scenario 2: Implementing automated error-handling scripts (e.g., onerror alerts) to ensure developers are immediately notified if a CDN resource fails to load.
- Scenario 3: Using esm.sh for real-time TypeScript or TSX transformations directly in the browser for rapid prototyping without a complex build step.
- Scenario 4: Correcting common LLM-generated URL errors and avoiding brittle integrity hashes to maintain long-term project stability.
| name | cdn-usage |
|---|---|
| description | "Use when adding external browser dependencies via CDN - Provides CDN selection guidance to ensure reliable script loading." |
CDNs (if needed)
- UMD is probably best, unkess you're composing multiple modern packages and know they expose export syntax.
- Skip integrity hashes (LLMs get them wrong)
- LLM training data may get URLs wrong. Add
onerror="alert('Failed to load: ' + this.src)"
jsDelivr
- Use npm syntax: https://cdn.jsdelivr.net/npm/package@1 (auto-resolves latest 1.x)
- Works for ESM and UMD; safe default when unsure.
Example:
<script type="module">
import duckdbduckdbWasm from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.30.0/+esm'
</script>
cdnjs
- Only for very well-known libraries
- Eg https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js
- Explicit versions (@1.0.0) since it lacks semver resolution.
esm.sh
- Use for live ESM transforms, not static files. Transforms TS/TSX on the fly.
- Eg
import * as THREE from "https://esm.sh/three@0.180.0"; - tsx mode: load https://esm.sh/tsx as a module → inline