Enabler to make scripts loaded from CDN more secure (#1127)

* added integrity property to load scripts

* fix contribution
pull/1124/merge
Michael Kolb 2024-10-25 10:38:37 +02:00 committed by GitHub
parent 8acb112e4e
commit e83f3ebc66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -90,9 +90,14 @@ function updateHeight() {
} }
} }
function loadJsByUrl(url) { function loadJsByUrl(url,integrity=null) {
const script = document.createElement("script"); const script = document.createElement("script");
script.src = url; script.src = url;
if(integrity){
script.integrity=integrity;
script.crossorigin="anonymous";
}
return new Promise((resolve) => { return new Promise((resolve) => {
script.onload = resolve; script.onload = resolve;
@ -104,4 +109,4 @@ function loadJsByUrl(url) {
<body> <body>
</body> </body>
</html>`; </html>`;