I have an angular application with below index.html file
Consider in my index.html page I have the following code for SRI (SubResource Integrity)
If I understand your question correctly, you want to use Sub Resource Integrity for scripts referenced via require js. Note, that in order to do this you need RequireJS version 2.1.19 or later (see http://requirejs.org/docs/download.html).
For a working example (referencing jQuery), see this plunker: http://plnkr.co/edit/kzqLjUThJRtoEruCCtMt?p=preview. Hopefully you should be able to copy this method to your project.
My example uses integrity/crossorigin attributes for:
index.html
file)main.js
and the interesting thing for you)This is built on the RequireJS hook onNodeCreated
and code like
onNodeCreated: function(node, config, module, path) {
node.setAttribute('integrity', integrityForModule);
node.setAttribute('crossorigin', 'anonymous');
}
Please note that this example does NOT use SRI for the config file main.js
file. In order to accomplish that, either
index.html
pagemain.js
(the config file) through an extra script tag (with integrity/crossover), and not via the data-main
attribute