Fork me on GitHub

Let's imagine your application contains
1. a set of thumbnails that, when clicked, must open a bigger version of the file in a pop-up.
2. an input field that, when focused, opens a datepicker widget
3. an image that, when hovered, shows a magnifying glass.
The question is:

Do you need to load the lightbox, datepicker and zoom-in files before the user performs those actions?

Yes, the correct answer is No!

myFeaxures.register('datepicker', {
    'attachEvent': 'focus'
    'files' : ['/vendor/datepicker/datepicker.css!css', '/vendor/datepicker/datepicker.js!js'],
    'attach': function(element, options) {
        $(element).datepicker(options);
    }
});

Other options for the attachEvent attribute are, as you probably have guessed, click and hover. The default value is domReady.

Are you a control freak?

If you want to decide exactly (to the milisecond) when an enhancement should be applied to an element you can do that too.

myFeaxures._attachToElement('datepicker', $('#my-birth-date'));

This will load the files, check if the element is a viable candidate for the enhancement and, most likely, nourish your god complex.