Replied to a post on waterpigs.co.uk:

[10:44] so say you want all textareas with class=“codemirror” to have codemirror applied to them, but not to load codemirror at all on pages without said textareas

[10:45] you call enhanceEach(‘textarea.codemirror’, [‘path/to/codemirror’ (requirejs dependency list)], callback)

[10:45] and if there are any elements matching the selector, the libraries are loaded, and callback(element, *dependencies) is called for each element

[10:46] it’s a pattern I use everywhere in Taproot and Shrewdness, and got tired of writing it out explicitly :) barnabywalters in IWC:IRC

Mentions: