How to Compress the Whole Directory Using xz and tar

I compressed a directory having 37M size using both xz & zip. The zip file size was 31M, while the xz file was 16M after compression. Pretty impressive, isn’t it? Let us see how to compress the whole directory using xz and tar on Linux, macOS/*BSD/Unix CLI.