Just an extremely quick and dirty trick I’ve used for a while now I thought I’d note down somewhere. It’s horribly inelegant and almost definitely very very wrong. You should definitely not do this.

In the ‘Site Assets’ library of a site, create an ‘htmlbits’ folder. In this folder, create a file with the format myFunction.html.bit. (The .bit extension stops various bits of SP machinery – such as SP Timer Jobs – from messing with your HTML)

Then, use these snippets in on a page with a Content Editor Webpart.  Simply set the title of a Content Editor Webpart to the name of the HTML bit, set the Content Link to the .html.bit’s path, and set the title not to display. Your .html.bit file will be injected into the page, and SharePoint will not mess with your code!

This seems to bypass SharePoint’s HTML filtering, and it’s handy for debugging. A sort of nicely self-documenting and simple way for a designer simply trying to inject some HTML, CSS, and JS into a page.The deployment workflow is simple. Save and refresh.

I should also point out that it is potentially going to be frowned on by the security gurus at MS, who may see it as a bug. Dunno – not a security expert.

Anyway, once you have reached a solution using this trick, you should consider whether you can generalize what you’re doing into the master page, or the page layout, or deploy a custom solution using visual studio that can do this in a neater way. Don’t forget to delete the htmlbits folder when you’re done.


Forgot to note that Waldek Mastykarz has a different method which some may find more appropriate for their needs.