Server-side word's generator isn't the best idea. Use instead client-side. You can use server to get list of words or any other source of them. Below two samples for your project:
// 1. Array
var words = ['One', 'Morning', 'Star'];
// 2. String
var text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum euismod nisl a malesuada laoreet. Vivamus consequat, mi vel fermentum ultricies, dui libero ullamcorper velit, eu hendrerit lacus lorem a lacus. Suspendisse id diam quam. In tristique risus non turpis feugiat sagittis. Nam vitae turpis tincidunt leo faucibus ultrices. Suspendisse tristique pharetra ante, sit amet luctus odio. Pellentesque libero tortor, lacinia in mattis ut, ullamcorper a enim. Donec gravida, neque eget lacinia porta, quam ex rhoncus sem, ac semper ligula lacus non ligula. Vivamus id risus convallis, rhoncus nisi et, efficitur magna. In sit amet dolor ut dui accumsan dignissim. Curabitur lobortis nisi eu sapien accumsan luctus. Nullam blandit turpis ut massa ultricies cursus.";
var wordFromArr = words[Math.floor(Math.random() * words.length)];
var wordFromString = text.split(" ")[Math.floor(Math.random() * words.length)];
document.getElementById("output").innerText = wordFromArr;
<div id="output"></div>