How to embed JavaScript script in front of ,</body> tag

It can only be placed at the end of the body. This is to initialize the player after the page has finished loading.