(function($){ $(function() { //make sure cycled element exists if(document.getElementById("npi")) { $('#npi').cycle({ timeout: 5000, speed: 200 }); } }); })(jQuery);