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)
Table of contents Overview definition Instance Me...
This article example shares the specific code of ...
Table of contents splice() Method join() Method r...
Adding the attribute selected = "selected&quo...
Table of contents Manual deployment 1. Create a s...
Recommended reading: MySQL 8.0.19 supports accoun...
VMware Preparation CentOS preparation, here is Ce...
This time we use HTML+CSS layout to make a prelim...
1. Text formatting: This example demonstrates how...
In CentOS7, when we install MySQL, MariaDB will b...
Sometimes it is necessary to perform simple verif...
Table of contents 1. Write in front 2. Overlay to...
Preface When we write code, we occasionally encou...
First, let me explain the version of MySQL: mysql...
This article describes how to install and configu...