CDN SDK
JavaScript API
Available methods and functions
Overview
The SDK exposes a global window.IconSDK object with useful methods.
Methods
hasIcon()
Check if an icon exists in your project.
IconSDK.hasIcon('home') // → true
IconSDK.hasIcon('nonexistent') // → falsegetAvailableIcons()
Get list of all available icons.
const icons = IconSDK.getAvailableIcons()
// → ['home', 'search', 'user', ...]preload()
Preload icons for better performance.
await IconSDK.preload('home') // Single icon
await IconSDK.preload(['home', 'search', 'user']) // Multiple iconsPreload icons that appear above the fold for instant display.
Use cases:
- Icons visible on page load
- Modal content that will appear soon
- Navigation menus
load()
Manually load a specific icon element.
const element = document.querySelector('[data-icon="home"]')
await IconSDK.load(element)clearCache()
Clear the in-memory icon cache.
IconSDK.clearCache()When to use:
- After updating icons in dashboard
- Debugging icon display issues
- Memory management in long-lived apps
reload()
Force refresh the SDK script (useful for development).
IconSDK.reload()This will reload the entire SDK. Use only when needed.
init()
Manually initialize all icons on the page.
IconSDK.init()Note: This is called automatically on page load. Only use if you need to re-scan the DOM.
stopObserver() / startObserver()
Control the MutationObserver.
// Stop watching for new icons
IconSDK.stopObserver()
// Resume watching
IconSDK.startObserver()Use cases:
- Temporarily pause icon loading during heavy DOM updates
- Performance optimization for batch operations
- Manual control over icon loading behavior
Properties
version
Get the SDK version.
console.log(IconSDK.version) // → "1.0.0"icons
Access the internal icons map.
console.log(IconSDK.icons)
// → { "home": "https://cdn.icon.dev/...", ... }cache
Access the internal cache.
console.log(IconSDK.cache)
// → Map { "home" => "<svg>...</svg>", ... }Next Steps
- Framework Integration - Use SDK with React, Vue, Svelte
- Best Practices - Performance tips
- Troubleshooting - Common issues and solutions