Filtering hidden and non-js files when reading a directory