Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Practice the basic mechanics of Express middleware.
Favicons
You might notice the fav.js
file used in this basic app. You can ignore it for now, but in case you're curious why it's there, read on! When you navigate to a URL with a browser, it will usually make two requests behind the scenes. One request will be for the resource you're requesting, usually a webpage, and the other will be for a favicon file to display in the browser's tab.
This means that if a middleware function logs a message to the console with every request (as some of the ones we will write do), that message will appear twice with every page refresh! fav.js
is a small piece of middleware that circumvents this issue so that we can read the output in this workshop without distraction. By the way, after you complete this workshop, you should be able to understand the code in fav.js
!
Note that fav.js
only exists for educational purposes, and should not be included in a production app. A real-life application should always supply a favicon to the browser.
- To read more about favicons, see this Wikipedia article.
- Express middleware for handling favicons
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up