Can I use subresource integrity when importing ES6 modules?

This code is as follows:

import { el, mount } from 'https://unpkg.com/redom@3.2.1/dist/redom.es.js';

Is there a way to enable subresource integrity checking to ensure that the CDN resource returns the expected content?

+4
source share
1 answer

You can use RequireJS and convert your code to AMD or UMD to achieve this. RequireJS has a hook onNodeCreatedthat gives you access to the script tag before adding it to the document. You can add the attribute srito the tag script:

onNodeCreated: function (node, config, module, path) {     node.setAttribute( "", );    node.setAttribute('crossorigin', 'anonymous'); }

: fooobar.com/questions/833768/...

Webpack ( UMD) RequireJS. , external webpack, .

0

Source: https://habr.com/ru/post/1684155/


All Articles