Hacker News new | ask | show | jobs
by BinaryIdiot 4052 days ago
Not a half bad idea but most of this is already covered in awesome resources like the MDN. This would have been perfect 5 years ago but I'm not necessarily convinced of its usefulness today. The MDN has examples and explains the why and how; this just has examples.

One nit pick from my browsing on the site

>> Alternatively, use DOM methods for creating content nodes and append them to the new element. This approach requires more code, and is in general slower or equally fast as working with innerHTML

So I would suggest using best practices and simply omitting the innerHTML bit versus laying out all of the possible options. Yeah there are cases where it's faster but that's not always the case and using things like createTextNode() will actually escape html for you so you don't have to worry about sanitizing input into innerHTML calls. Naturally there is innerText but I'm not sure all browsers support that.