Get started with embed-js CDN

MIT licensed

The embed-js library is a lightweight JS solution for easily embedding external content into websites.

Tags:
  • JavaScript-plugin
  • embed
  • plugins
  • JavaScript
  • embed-js
  • emoticon
  • jquery-embed

Stable version

Copied!

How to start using embed-js CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with embed-js CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/embed-js/5.0.4/embed.min.js"></script>
</head>
<body>
    <button id="loadEmbedButton">Load Embed</button>
    <div id="embedContainer"></div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const loadEmbedButton = document.getElementById('loadEmbedButton');
            const embedContainer = document.getElementById('embedContainer');

            loadEmbedButton.addEventListener('click', () => {
                const iframe = document.createElement('iframe');
                iframe.src = 'https://example.com';
                iframe.width = '560';
                iframe.height = '315';
                iframe.frameBorder = '0';
                iframe.allowFullscreen = true;

                embedContainer.innerHTML = '';
                embedContainer.appendChild(iframe);

                embedJs('iframe')
                    .load('https://example.com')
                    .size('560', '315')
                    .autoplay(true)
                    .apiKey('YOUR_API_KEY') // Replace with your API key
                    .then(() => {
                        console.log('Embed loaded successfully');
                    })
                    .catch((error) => {
                        console.error('Error loading embed:', error);
                    });
            });
        });
    </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions