Features / Changes:
- Remove dependency on jQuery.
- Use HTML5 data-* attribute (not the jQuery.data()). It's better for debugging and work with other scripts. eg. You now able to query it directly: document.querySelectorAll(["data-drupal-once"]))
- Performance improvements
- Fully pass jQuery.once testcases
- Light weight & More easier to adopt other libs. eg. Converting to jQuery Chaining way: https://github.com/KayLeung/dropletOnce/blob/master/jquery.droplet.once.js
Performance testing result:
** Noticeable performance diff on iPhones.
The reason I do not like jQuery.Once 2.0:
- jQuery adding overhead. Including libs size and execution time ( I'm doubt the performance improves between jQuery Once 1.0 .class way and Version 2.0 jQuery.data on modern browsers )
- No standard identify for themer (.once-class)
- No visual debugging info for themer ( You can't see the Onced elements in devtools. You must use JS to loop over to see if that elements if Onced or not. This is not friendly for HTML/CSS themers)
- One way synced only. jQuery.Once 2.0 use jQuery.data to track Onced elements. It will not synced back to HTML DOM.
- Not a modern way. Popular frameworks use standard HTML5 data-* attribute. Not the jQuery.data()