You have an HTML, JavaScript or CSS snippet that you want to inject into the page, without having it been cleaned out by the SharePoint editor?

Well this article is for you, so let's start.

Step 1: Add the Script Editor Web Part

From ribbon bar, click on Web Part (you can add it anywhere on the page, it does not matter, as it will not render anything)

Under Categories choose Media and Content > Script Editor and click Add

Step 2: Edit the Web Part

Activate the Web Part by clicking it, then a new tab Web Part in the ribbon will appear

Then next, click on the Web Part Properties button

Step 3: Add the Code into the Web Part

The page will refresh, and the Script Editor Web Part will appear now in edit mode, click on Edit Snippet, to bring up the dialog that will allow you to paste some JavaScript code into the page.

Now you can paste whatever HTML code you have into the Embed Dialog

Script tags are required when adding custom JavaScript to your Sharepoint Site