1) Create the following regular text file
<!-- JS code goes here -->
and upload it into Site Assets library
2) Add a reference to a file via via Content Link web part property
As mentioned in the blog post you references, it simply needs to happen after the response has been created (i.e. the page content) and before the UpdateRequestCache event. The blog post shows an idea example of using the PostRequestReleaseState event. This happens almost immediately after the response is generated.
public void Init(HttpApplication app)
In IIS8 (which you are using, if you are using SharePoint 2013) it uses ASP.NET 4.5. The application events are different from 3.5 and are raised in the following order:
After the PostResolveRequestCache event ...
You can enable it via the web.config in IIS as shown in How to enable HTTP Strict Transport Security (HSTS) in IIS7+. With that said, it may or may not break something -- 2016 and above are specifically tested with it.
I had in past used Copy.CopyIntoItems service referenced at https://msdn.microsoft.com/en-us/library/websvccopy.copy.copyintoitems(v=office.15).aspx to copy major version of file from one library to another library while preserving version history on target. This worked for SharePoint 2010.
I used below code.
CopyService.Copy copySvc = new ...