You should make a function that reads the data from file when the page loads:
window.onload = function() { var fileContent = fs.readFileSync(filePath, 'utf-8'); var lines = fileContent.split('\n'); };