Wednesday 6 April 2016

conditionally load js or css files using jquery

Introduction:

 Here i am going to explain how to load css or js files conditionally.


Step 1:
           For example if u want to load some js files really if need not for all the times. There is a solution to load files conditionally with jquery.

  1. <script>  
  2.    
  3.  $('#btnLoadJs').on('click', function () {
  4.             $.getScript('../js/awsome-complete.js', function (data, textStatus, jqxhr) {
  5.             });
  6.         });
  7.             </script>

On btnLoadJs click the file will be downloaded. Not for all the time when page is loaded.

No comments:

Post a Comment