Disclaimer: This was a POC and shouldn't be used in Production. I recommend building your web apps with something like Svelte, Vue, or React.
Prototyping pure JavaScript with parts of jQuery I actually use and like.
Pick and choose from any of the modules, the minified folder contains prototype.min.js that has all of the modules merged into one file.
conststyles={
el.style.color='red'el.style.fontSize='14px'}// Beforeconstparent=document.querySelector('#parent')constchilren=parent.querySelectorAll('.child')children.forEach(el=>{el.addEventListener('click',e=>Object.assign(el.style,styles))})// Afterconstparent=select('#parent')constchilren=parent.select('.child')chilren.on('click',e=>e.target.css(styles))// And because all of the modules return their Node or NodeList you can chain your methods:constheaderList=select('h1').css({color: 'blue'}).on('click',e=>console.log('click'))// headerList = NodeListNode.prototype.select=function(query[,limit=true])A vaild CSS selector string
If truthy and there is only one element a Node will be returned. If falsey and there is only one element a NodeList will be returned.
Node or NodeList
// Beforeconstparent=document.querySelector('#parent')// Nodeconstchildren=parent.querySelectorAll('.child')// NodeList// After constparent=select('#parent')// Nodeconstchildren=parent.select('.child')// NodeListNode.prototype.css=function(css)An object containing valid JavaScript style keys and values
Node or NodeList
conststyles={color: 'red',fontSize: '14px'}// BeforeObject.assign(parent.style,styles)children.forEach(el=>{Object.assign(el.style,styles)})// Afterparent.css(styles)chilren.css(styles)The events module just wraps the built-in addEventListener and removeEventListener.
Node or NodeList
// Beforeparent.addEventListener('click',eventHandler)children.foreach(el=>{el.addEventListener('click',eventHandler)})// Afterparent.on('click',eventHandler)children.on('click',eventHandler)The project is licensed under the GNU General Public License v3.0. - see the LICENSE.md file for details