Hi Donboe, one is just a shortcut for the other. That is to say they are equivalent.
Personally, I prefer the the second, $(function() {});. Or better still, put your JavaScript before the closing body tag and do away with the check altogether.
The jQuery code waits for the DOM to be loaded before running the function.
With vanilla JavaScript we achieve the same thing by placing our scripts at the end of the body, just before the </body> tag.
That is also jQuery code that does the same thing. It’s a shortcut for the first code.
The following page shows several different ways that jQuery lets do the same thing, of waiting for the document to be ready before running the JavaScript.