Mega.js is a javascript library that adds more shortly named aliases of document.querySelector and EventTarget.addEventListener.
// element selection
$('span.code').innerHTML = 'Hello, World!'
// add an event listener
$('span.code').on('click', function() {
console.log('code was clicked')
})
// the .on method is added to all objects,
// not just those returned by $
document.body.lastChild.on('touchstart', function() {
console.log('document.body.lastChild was touched')
})
// you can only pass strings to $
// the following will result in an error
$(window).on('load', function() {
$('span.code').focus()
})
// solution: don't use $
window.on('load', function() {
$('span.code').focus()
})