Check if jQuery function exists

Benchmark created by jordifreek on


Description

Use jquery isFunction to determine if a there're a jQuery UI function.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery isFunction
jQuery(document).ready(function() {
if (jQuery.isFunction(jQuery.fn.datepicker)) {
    console.log('ok')
}
});
ready
No isFunction
jQuery(document).ready(function() {
if (jQuery.fn.datepicker) {
    console.log('ok')
}
});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by jordifreek on