drupal_add_js best practice to include inline code or script file While reading the API page for drupal_add_js, I kept wondering what is the best practice to include inline JavaScript or a JS file.

It seems like it works exactly the same even if you omit 'file', 'external' or 'inline' like in this example : 

Without 'file'

drupal_add_js('misc/collapse.js');


With 'file'

drupal_add_js('misc/collapse.js', 'file');


So the question is rather simple. Why would I choose one over another and what is the standard way of coding this ?

Thanks !
They are both and the same. The fileparameter you have specified in your second example is the same as the first example as it's the default type.


  type: The type of JavaScript that is to be added to the page. Allowed values are 'file', 'inline', 'external' or 'setting'. Defaults to 'file'.


Source: drupal_add_js

If your question is about whether it's best practice to use inline or file then it depends on your requirements. If you need to load a JavaScript library or a large amount of JavaScript then I would use file type. If you are just loading say some tracking code, or a few lines of JavaScript then I would probably use inline as it's one less HTTP request.