I have a question about node.js/javascript. It might be a little bit of a beginner question so feel free to see what solution I should use. I have a .js file that I execute with the below command in the commandpromt.
node test.js
When executing that command, it takes about 3 seconds for the commandprompt to log "start". Is this because it takes 3 seconds to load the overhead in the beginning?
For example if looking at the below code. I would like the javascript to wait for a file "C:/test/test.txt" and when this file exists, start to execute the code below. But if I need to execute the whole test.js file it will first take 3 seconds to load the overhead?
Please ask if I am not clear enought but, - I beleive my question is how it is possible to either already have the overhead loaded/cached for the code to wait for the file and instantly run the code?
'use strict';
const ccxt = require('ccxt');
const fs = require('fs');
const path = require('path');
//Here, I would like to let the code below react INSTANTLY
//when for example this file Exists: "C:/test/test.txt"
//It takes 3 seconds before the code starts here
//Here the code begins.
console.log(`start`);