how to add script before </body> in magento 2 code example
Example: how to add script before in magento 2
Add referenceContainer code in layout file
app/design/frontend///Magento_Theme/layout/default.xml
Before body end
For after body start
Create js.phtml template file and put your js script/code in this file.
app/design/frontend///Magento_Theme/templates/js/js.phtml