The new relic documentation shows how to do custom installations of the page load timing framework at:
https://docs.newrelic.com/docs/java/page-load-timing-in-java
What would be the easiest and cleanest way to install this in the Apache Cocoon based DSpace XMLUI?
Today page load timing goes under the product name "New Relic Browser". The latest docs are available at:
The "select an app" deployment option doesn't work for XMLUI in DSpace because it isn't using JSP's. However, the "Copy/Paste Javascript" option does work.
As a first step, you need to get the application specific javascript snippet by going through this procedure:
To install the javascript in your live deployed XMLUI webapp, running the Mirage 2 theme, you need to:
Add the JS script as a separate file in /xmlui/themes/Mirage2/scripts. Give the script a meaningful name, for example newrelic-browser-performance.js. When you do this, REMOVE the script tags at the start and the end of the snippet provided by New Relic.
Include the script AFTER the viewport and BEFORE the shortcut icon link at xmlui/themes/Mirage2/xsl/core/page-structure.xsl with following tag:
<script src="/themes/Mirage2/scripts/newrelic-browser-performance.js"> </script>
Note that this is not really the proper way to add just any javascript to a mirage 2 based theme. Normally, all you need to do is add the link to the script in your scripts.xml file and there would be no need to modify page-structure.xsl. However, this will have the result that the javascript will be invoked at the bottom of the page, rather than high up in the HEAD. Therefore, the method I provided does exactly this, invoking the script high in the HEAD because this is listed in the installation instructions. If you are worried that doing this might slow down the loading of the page, you can always try the default method and see what happens.
For a Mirage 1 based theme, the approach is similar, but the javascript files are stored in the /js/ folder and not in /scripts/