Check if a module is enabled with JavaScript How do I check if a module is enabled using JavaScript? I want to avoid unnecessary Ajax calls that cause 403 errors since the module is not enabled.

if (mymodule_exist) {
  // Make an Ajax call.
  jQuery.ajax({
    url: "/player/status",
    type: "POST",
    async: false,
    success: function(data) {
      player_value = data;
    }
  });
}


I am trying to do something like this. How do I do it efficiently?
I can think of two ways:


Send a JavaScript flag as settings, indicating the module is active:

drupal_add_js(array('my_module' =&gt; array('enabled' =&gt; TRUE)), 'setting');

If the module is enabled, modify the output in some way so the JavaScript code that makes the petition is included only when your module is enabled, or the contrary way, make sure that code is not included if your module is disabled: you will have to use another module or some kind of configuration. The exact way depends on the origin of the JavaScript code that makes the Ajax petitions.