1. Import files using script tags In 1. Import local files The development environment generally introduces local <script src="./js/index.js"></script> 2. Import remote files After deployment online, it is generally distributed to Such as: <script src="https://cdn.xxx.xx/js/index.js"></script> However, there is a problem with introducing remote files. If the corresponding files are tampered with, it may affect the users. Although In this case, security verification can be performed through the 2. Integrity Security Verification Such as: <script integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" src="https://cdn.xxx.xx/js/index.js"></script> 1. Import Vue's CDN resourcesFor example, we want to introduce the CDN resources of Vue:
You can generate the hash value through https://www.srihash.org/. Integrity generates hash value: Finally, add the value of <script src="https://unpkg.com/[email protected]/dist/vue.global.js" integrity="sha384-0k9//QJdpmfSdp5IK3oJjOYPfz42f2FE0goMLtK9Vq7aKllvc4Lnz7lHPHiFhvDP" crossorigin="anonymous"> </script> 2. Verify whether it is normal Because the imported resource is a Eventually the browser will report the following error:
This means that This is the end of this article about using the integrity attribute for security verification in JavaScript. For more relevant script integrity content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Application of anchor points in HTML
>>: What are the benefits of using // instead of http:// (adaptive https)
When logging in to the stress test, many differen...
Table of contents Same Origin Policy Ajax request...
Closures are one of the traditional features of p...
1. Composite primary key The so-called composite ...
Table of contents Standard execution process opti...
Preface Linux has corresponding open source tools...
This article shares the specific code of js+canva...
Delete the previously installed mariadb 1. Use rp...
Open Source Database Architecture Design Principl...
nginx Nginx (engine x) is a high-performance HTTP...
This article example shares the specific code of ...
Mouse effects require the use of setTimeout to ge...
Implementation effect: 1. count(1) and count(*) W...
What is a Port? The ports we usually refer to are...
Table of contents The first method: When the MySQ...