Try it yourself:
go to youtube and take a look at the navbar if the window size is smaller than 700px the logo changes.
I inspected the resources of the html css files of the page but couldn't find out how youtube does it.
If anyone knows the trick or has a guess - please answer.
they use the
Responsive Web Design (Media Queries) :