Get started with prototype CDN

MIT licensed

Open-source library: Prototype - DOM, events, Ajax for dynamic web apps.

Tags:
  • framework
  • toolkit

Stable version

Copied!

How to start using prototype CDN


// Include Prototype library
const script = document.createElement('script');
script.src = "https://cdn.cdnhub.io/prototype/1.7.3/prototype.min.js";
document.head.appendChild(script);

// Wait for the library to load before executing the code
window.addEvent('domready', function() {
  // Create a new Element
  const newElement = new Element('div', {
    'id': 'my-new-element',
    'class': 'my-class',
    'html': 'Hello, Prototype!'
  });

  // Insert the new Element into the body
  document.body.insertBefore(newElement, document.body.firstChild);

  // Add an event listener to the new Element
  newElement.addEvent('click', function() {
    new Element('p', {
      'html': 'You clicked me!'
    }).insertBefore(newElement, newElement.firstChild);
  });
});
Copied!
Copied!

All versions