Good practice for initializing libraries

Initializing a js library, a good way to do it would be wrap it inside an if condition. e.g. initializing the flexslider library:

(function() {

    if (typeof $.fn.flexslider === 'function'){

        $('.flexslider').flexslider({
            direction: "vertical",
            controlNav: false,
            directionNav: false
        });

     }

})();

the typeof operator can be used with any JavaScript library, to ensure that we don't initialize a library unnecessarily if the library is not available on the site.