You've included HTML5 as a tag, so I'm going to assume you want to create an web-page that has IM functionality built in.
UCWA is exactly what you need in this instance. UCWA is a rest-like API for accessing Lync for IM and Presence. You can use UCWA with anything that does HTTP request/response, but all the examples are using Javascript. Have a look at UCWA.Lync.com - where you will find online examples and code samples.
Also, if you're developing a project on this, depending on your timeline, you should also be aware of a new technology recently announced at the Lync Conference 2014. Its code name is JLync, and it will bring "browser extensibility with voice, video & content."