I’ve noticed that $(document).ready(..) causes a noticable delay in applying javascript effects. However I also understand that just having the effect in a <script> can not always work because the DOM may not be ready.
When should you always put your code in $(document).ready and when is it ok to bring it out into a global <script> tag?
There’s no set rule for when you should and should not use it. The answer lies in whether or not your code needs to traverse parts of the DOM that won’t exist when it executes. If you need to find an element by ID you can use this to let the DOM build before your code executes. If you don’t care about the DOM then you don’t need to use it.
The other approach is to move your script tags to the bottom of the body tag so that they are executed after the DOM has loaded. There’s no major advantage / disadvantage to doing this either way, but it does make it harder to keep your code organized, while using $(document).ready() allows you to keep javascript in the head of your page even if it needs to execute at the end.