Added check for .js files when reading from dir