I inserted your exact code into my test site and it worked fine.
You can see that it does work here
where you have added the code to the <head> element.
Regarding your sidebar disappearing, are you sure it's related to the <head> code? Could it be something in your widget settings?