What's the difference between using $CONFIG->wwwroot and elgg_get_site_url()?

The usage of $vars['url'] should be replaced by using elgg_get_site_url(). Got that.

But then there's also often used "echo $CONFIG->wwwroot" and replacing this by elgg_get_site_url() seems to fail for example in case of document.location.href='<?php echo $CONFIG->wwwroot"; ?>some/url'". In this case replacing "echo $CONFIG->wwwroot" by "echo elgg_get_config('wwwroot')" would be an alternative. But why does elgg_get_site_url() fails to work.

Also, I'm unsure what to use in calling actions via $.post().

Can anyone enlighten me, please?