Posts

Showing posts with the label jquery best pratices

jQuery Best Pratices

 jQuery Files a) Try to use Jquery CDN where possible.                  <script type= "text/javascript"   src= "//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" ></script> <script>window.jQuery || document.write( '<script src="js/jquery-2.1.1.min.js" type="text/javascript"><\/script>' )</script>     Implement a fallback to locally hosted jQuery file of same version in-case CDN is not working.(as above)  b) DO NOT use jQuery version 2.x if you support Internet Explorer 6/7/8. c) If you are using other libraries like Prototype, MooTools, Zepto etc. that uses `$` sign as well, try not to use `$` for calling jQuery functions and instead use `jQuery` simply or use `$.noConflict()`.    jQuery Variable a) Better to start with  `$`  while  naming jQuery variable so it will be easy to understand and later on manipulate. ...