TrustLabs SDK - CDN Usage Examples
1. Automatic Detection (Zero Configuration)
Simply add the trust-email class to any email. The SDK will auto-detect and render badges:
John Doe - CEO
Email: john@company.com
Role: Chief Executive Officer
Jane Smith - CTO
Email: jane@company.com
Role: Chief Technology Officer
Bob Johnson - Lead Dev
Email: bob@company.com
Role: Lead Developer
<span class="trust-email">user@example.com</span>
2. Manual Rendering
For more control, manually trigger badge rendering:
Sarah Wilson - Designer
Email: sarah@company.com
// Manual rendering
window.TrustLabsSDK.renderTrustBadgeWithFetch({
targetEl: document.getElementById('manual-email'),
emails: ['sarah@company.com']
});
3. Batch Processing
Process multiple emails at once for better performance:
Alice Brown
alice@company.com
Charlie Davis
charlie@company.com
Diana Evans
diana@company.com
// Batch processing
const emails = ['alice@company.com', 'charlie@company.com', 'diana@company.com'];
const trustData = await window.TrustLabsSDK.getTrustStatus(emails);
emails.forEach((email, index) => {
const element = document.querySelector(`[data-email="${email}"]`);
window.TrustLabsSDK.renderTrustBadge({
targetEl: element,
trustData: [trustData[index]]
});
});
4. Error Handling
Handle errors gracefully:
Invalid Email Test
Email: invalid-email-format
try {
await window.TrustLabsSDK.renderTrustBadgeWithFetch({
targetEl: element,
emails: ['invalid-email']
});
} catch (error) {
console.error('Badge error:', error.code, error.message);
// Handle error appropriately
}