Using <script>
tags to load JavaScript files is pretty straightforward for any developer. But have you ever wondered what happens if any of these scripts are tempered before loading into the browser?
The answer is obvious. It could lead to a severe security breach exposing sensitive data.
Therefore, we need to have safety measures to verify the integrity of these scripts to prevent it from happening. And one of the most popular solutions is Sub Resource Integrity (SRI) in modern browsers.
SRI is a security feature that allows browsers to check the resources they fetch. It will make sure that the code is never loaded if the source has been manipulated.
It enables developers to identify whether the third-party resource they are loading has been tampered with by verifying its integrity code.
But, what is an integrity code? How can we use it in our applications?
I will answer these questions in the coming sections.
#javascript