jQuery datatables: test if datatables plugin is initialized

First, add a special class name when you're initializing datatables:

$('.datatable').not('.initialized').addClass('initialized').dataTable()

And now you can tell them apart by class name:

alert( $('#datatable').hasClass('initialized') )

You can the fnIsDataTable function in jQuery datatable

var ex = document.getElementById('example');
if ( ! $.fn.DataTable.fnIsDataTable( ex ) ) {
  $(ex).dataTable();
}

You can find more information in api


I feel following is the right answer to this.

$(document).ready(function(){
    if (jQuery().dataTable) {
         // your code to do some detaul set ups 
    }
});

For example

$(document).ready(function(){
    if (jQuery().dataTable) {

            $.extend( $.fn.dataTable.defaults, {
                iDisplayLength : 200,
                aLengthMenu : [[100, 200, 300, -1], [100, 200, 300, "All"]],
            });
        }
});

By this way you if(jQuery().<libname>) should be able to check any library loaded or not.