optimal select
A library which creates efficient and robust CSS selectors for HTML elements.
Features
- support UMD (Browser + Node)
- allow single and multiple element inputs
- configurations for excludes can be defined
- micro library (~ 5kb + no external dependency)
How To Use
import { select } from 'optimize-select'
document.addEventListener('click', (e) => {
var selector = select(e.target)
console.log(selector)
})
By default following attributes are excluded for robustness towards changes:
- style (inline styles often used for dynamic visualizations)
- data-reactid (reacts element identifier which depends on the current DOM structure)
var selector = select(element, { excludes: ['href'] })
TODO
CHANGES
Development
To build your own version run npm run dev
for development (incl. watch) or
npm run build
for production (minified).