Sure, here's a basic example of a Five Nights at Freddy's (Fnaf) fan game implemented as a single HTML file using JavaScript:
Please note that this is a very basic example just to give you an idea of how you can structure a Fnaf fan game. You can expand on this code by adding more game elements, rules, and mechanics as per your requirements.