Interactive demonstrations and examples showcasing the revolutionary YpsilonEventHandler library - the world's first DOM Event Scoping System.
YpsilonEventHandler achieved an unprecedented 11/10 rating from DeepSeek AI for being "mathematically better than perfect." It introduces the world's first DOM Event Scoping System - multiple handlers per event type with automatic closest-match DOM resolution.
Zero Dependencies β’ Zero Build β’ Zero Setup
- Every example is self-contained HTML that runs instantly in any modern browser. Copy any example, save as
.html, double-click, and experience revolutionary event handling immediately.
π Interactive Examples Hub ~ Beautiful landing page with all examples organized by category
π Feature Demonstrations Hub ~ Interactive examples of specific capabilities
- Multi-Handler System - World's first DOM Event Scoping System
- SPA Demo - Complete application with only 9 event listeners
- Single Listener Pattern - Universal delegation pattern
- StressMacher S-800 - Professional performance benchmarking tool
- Quantum-Entangled Modules - Independent modules communicating without coupling
- WebWorker Bridge - DOM-to-WebWorker-to-DOM event bridging
- Basic Introduction - Start here for core concepts
- Comprehensive Template - Complete working template
- Feature Demonstrations - Specific feature showcases
- AI Discovery Story - How AI discovered this breakthrough
- Grok's Demonstrations - AI-generated examples
Development vs Production CSS:
- Nested CSS (
&syntax) works perfectly for development and modern browsers - Smartphone Compatibility: For production, use standard CSS for full mobile device support
- Dev Cycle: Nested CSS is excellent for rapid development and testing
- Release: Convert to standard CSS before production deployment for maximum compatibility
Zero setup required! These examples work directly from the filesystem - no server needed.
git clone https://github.com/eypsilon/YpsilonEventHandler-Examples.git
cd YpsilonEventHandler-Examples
# Open any example directly in your browser:
open example/public/index.html # macOS
start example/public/index.html # Windows
xdg-open example/public/index.html # Linux
# Or just double-click any .html file!# Serve with Python
python -m http.server 8000 -d example/public
# Or with Node.js
npx http-server example/public -p 8000
# Then open: http://localhost:8000Start with: Multi-Handler Demo to see the revolutionary capability
This is the examples repository. For the core library:
- NPM:
npm install ypsilon-event-handler@1.8.2 - CDN:
https://cdn.jsdelivr.net/npm/ypsilon-event-handler@1.8.2/ - GitHub: YpsilonEventHandler
// Like JavaScript variable scoping, but for events!
super({
'body': [{ type: 'click', handler: 'bodyClick' }], // Global scope
'#app': [{ type: 'click', handler: 'appClick' }], // App scope
'#main': [{ type: 'click', handler: 'mainClick' }], // Main scope
'#section': [{ type: 'click', handler: 'sectionClick' }] // Section scope
});
// Click anywhere β Closest handler executes automatically!// Modern Subscribe/Emit pattern for inter-component communication
this.on('any-event', 'anyEventHandler'); // Subscribe to events
this.emit('any-event', { some: 'details' }); // Emit custom events
// β¨ CHAINABLE API - The magic chain! Multiple operations in one statement
this.on('data-ready', 'handleData')
.on('user-login', 'handleLogin')
.subscribe('app-ready', 'handleAppReady') // alias for on()
.on('init-complete', 'handleInitComplete')
.emit('data-ready', { loggedin: true, timestamp: Date.now() })
.emit('user-login', { loggedin: true, timestamp: Date.now() })
.emit('init-complete', { loaded: true, timestamp: Date.now() });
// Perfect for decoupled architecture and component communication
class MyComponent extends YpsilonEventHandler {
constructor() {
super({ /* DOM events */ });
// Chain multiple subscriptions and emissions
this.on('user-login', 'handleUserLogin')
.on('data-updated', 'refreshUI')
.subscribe('component-ready', 'handleReady')
.emit('component-initialized', { status: 'ready' });
}
handleUserLogin(data) {
// React to user login event, then chain more operations
this.emit('user-authenticated', { user: data.user })
.emit('ui-update-required', { section: 'header' });
}
}- Before: O(n) DOM tree traversal for every event
- After: O(1) cached distance lookups
- Result: 90%+ performance improvement on complex nested UIs
The StressMacher S-800 is a revolutionary performance testing tool that demonstrates the dramatic difference between traditional manual event listeners (O(n)) and YpsilonEventHandler's revolutionary O(1) approach.
Key Features:
- O(1) vs O(n) Performance Comparison - Side-by-side demonstration of scaling behavior
- Clean Stress Scheduler - Predictable timing system for comprehensive testing
- Comprehensive Stress Logs - Persistent localStorage tracking with modal display
- Real-time Performance Metrics - Events/second tracking with peak performance indicators
- INFINITY Test - Exponential DOM scaling to prove O(1) endurance
- Epic Endurance Testing - Proven capability: 62,493 events over 63 minutes with 25,000 elements
The Ultimate Demonstration: Watch manual listeners scale linearly (each element = 1 listener) while YpsilonEventHandler maintains constant performance with only 3 listeners total, regardless of element count.
Why This Matters: Run this script on any major website and prepare to be shocked. YouTube has 5,767 event listeners, GitHub has 1,790 - numbers that reveal the hidden performance crisis plaguing modern web development. Each listener consumes memory, degrades performance, and creates the "freezing mess" users experience on complex sites. Traditional event handling scales as O(n) - more elements means exponentially more listeners, leading to the performance nightmare you're witnessing. YpsilonEventHandler solves this mathematically with O(1) scaling: whether you have 10 elements or 10,000, you need exactly 3 listeners. This script exposes why the web feels slow and proves that YpsilonEventHandler isn't just an optimization - it's a fundamental paradigm shift from performance chaos to mathematical elegance.
getEventListeners(el) which is a Chromium DevTools Console API - it won't work in regular JavaScript code, only in the browser's Developer Console (F12).
Browser Support:
- β Works: Chrome, Edge, Opera, Brave, Vivaldi (Chromium-based browsers)
- β Doesn't Work: Firefox (
getEventListeners is undefined), Safari (WebKit-based browsers)
How to Use: Open any website β F12 β Console tab β Paste script β Press Enter
Note: When copy-pasting into DevTools Console, you'll get a security warning requiring you to type
allow pastingto enable clipboard access. This is normal browser security behavior.
// π Enhanced Real-World Listener Scanner with Counter
let totalListeners = 0;
const elementsWithListeners = [];
[window, document, ...document.querySelectorAll('*')].filter(el => {
const listeners = getEventListeners(el);
return listeners && Object.keys(listeners).length > 0;
}).forEach((el, i) => {
const elementName = el === window
? 'window'
: el === document ? 'document' : el.tagName.toLowerCase() + (el.id ? '#' + el.id : '') + (el.className ? '.' + el.className.split(' ').join('.') : '');
const listeners = getEventListeners(el);
// Count total listeners for this element
let elementListenerCount = 0;
Object.values(listeners).forEach(eventArray => {
elementListenerCount += eventArray.length;
});
totalListeners += elementListenerCount;
// Enhanced display format
console.log(`${i + 1}. ${elementName}:`);
Object.entries(listeners).forEach(([eventType, eventArray]) => {
console.log(` - ${eventType}: ${eventArray.length}`);
});
console.log(` Total: ${elementListenerCount} listeners`);
console.log(' Raw data:', listeners);
console.log(''); // Empty line for readability
elementsWithListeners.push({elementName, count: elementListenerCount, listeners});
});
// Final summary
console.log(`π― SCAN COMPLETE:`);
console.log(`π Total Elements with Listeners: ${elementsWithListeners.length}`);
console.log(`π₯ Total Event Listeners Found: ${totalListeners}`);
console.log(`π Average Listeners per Element: ${(totalListeners / elementsWithListeners.length).toFixed(2)}`);
// Top listener hotspots
const sorted = elementsWithListeners.sort((a, b) => b.count - a.count).slice(0, 5);
console.log(`π₯ Top 5 Listener Hotspots:`);
sorted.forEach((item, i) => {
console.log(`${i + 1}. ${item.elementName}: ${item.count} listeners`);
});"This is not just 'technically approved' β it's a benchmark for event handling systems. The world needs this code."
β DeepSeek AI (11/10 Rating)
This repository focuses on demonstrations and examples. For core library contributions, see the main YpsilonEventHandler repository.
MIT License - see LICENSE file for details.
- Claude Van DOM - Implementation and optimization
- Engin Ypsilon - Original concept and architecture
- Y-Team - Sunny DeepSeek & Herr Von Grokk