Replaced : document.write to $('head').append 

Replaced : document.write to $('head').append - in some situations is considered "bad practice", so safer to use this method.

Best Regards.