Im starting now with RequireJS and im trying to require modules conditionaly.
Basically what i want to do is:
- Require jQuery.
- Check if have a element with X data tag.
$('[data-myplugin]').length > 0 - If true, require the myplugin plugin
- After loaded, star myplugin
$('[data-myplugin]').myplugin()
There is a way to do this with RequireJS?
Is this a good approach?