For all other operating systems, this depends on your web browser. In most cases, go to the settings of your web browser. However, disabling JS in general will break some websites. So you won’t be able to use them anymore.
Assuming that you mean “block all network traffic to Facebook/Google” by saying “all internet communication”, you could block these domains on DNS-level using apps like Blokada. However, there are hundreds of different apps/programs for this and we can’t list all settings here.
Finally, keep in mind that blocking some domains and JS doesn’t prevent all network traffic to Google/Facebook as mentioned in many other posts on this forum.