moses toh
moses toh

Reputation: 13172

How can I make a certain script is not executed in the javascript?

My javascript code like this :

;(function($){

    $.ag.hideScrollbar = function (currentWidth) {
        ...
    };

    // not executed
    //start
    $.ag.initMap = function(mapCanvas){
        ...
    };
    $.ag.initMapAutocomplete = function () {
        ...
    };
    //end

}(jQuery));

I want map script not executed

I do not want to comment the script. I want to add a condition for the script not to run

How can I do it?

Upvotes: 0

Views: 40

Answers (1)

dippas
dippas

Reputation: 60563

you can add an if statement to that function

something like :

;(function($) {

  if (element.length > 0) { //or whatever condition you need to test
    $.ag.hideScrollbar = function(currentWidth) {
      ...
    };
  }

  // not executed
  //start
  $.ag.initMap = function(mapCanvas) {
    ...
  };
  $.ag.initMapAutocomplete = function() {
    ...
  };
  //end

}(jQuery))

Upvotes: 1

Related Questions