{"id":63398,"date":"2019-04-10T04:19:12","date_gmt":"2019-04-10T11:19:12","guid":{"rendered":"http:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/"},"modified":"2019-04-10T04:19:12","modified_gmt":"2019-04-10T11:19:12","slug":"understanding-subresource-integrity","status":"publish","type":"post","link":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/","title":{"rendered":"Understanding Subresource Integrity"},"content":{"rendered":"<link rel=\"canonical\" href=\"https:\/\/www.smashingmagazine.com\/2019\/04\/understanding-subresource-integrity\/\"><title>Understanding Subresource Integrity<\/title><\/p>\n<article>\n<header>\n<h1>Understanding Subresource Integrity<\/h1>\n<address>Drew McLellan<\/address>\n<p>                  <time datetime=\"2019-04-09T12:30:59+02:00\">2019-04-09T12:30:59+02:00<\/time><time datetime=\"2019-04-10T11:05:32+00:00\">2019-04-10T11:05:32+00:00<\/time><\/header>\n<p>If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking <code>integrity<\/code> attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code.<\/p>\n<p>All that junk is actually a really useful security feature called Subresource Integrity (SRI) that can help to defend your site against certain types of hacks and compromises. In this article, we\u2019ll take a look at what SRI is, how it can help protect you, and how you can start using it in your own projects, not just for files hosted on CDNs.<\/p>\n<h3>A Bit Of History<\/h3>\n<p>Way back in the days when JavaScript was very much the poorer cousin to HTML and CSS, we didn\u2019t need to think too much about how our scripts could be used as an attack vector for our websites. Most sites were all hosted on a single physical server somewhere on our own hosting infrastructure, and it was the server we thought about defending when it came to security best practices.<\/p>\n<p>As browsers became more capable and net connections got fatter, we started to use more and more JavaScript, and eventually, reusable JavaScript libraries began to spring up. In those early days, libraries like script.aculo.us, Prototype and eventually jQuery began to gain adoption amongst developers looking to add more interactivity into their pages.<\/p>\n<p>With these added libraries and subsequent plugins came added page weight, and before long we were starting to think seriously about front-end performance. Resources like Content Delivery Networks (CDNs) that had previously been the reserve of giant corporations were becoming commonplace for everyday folk building snappy websites.<\/p>\n<div data-component=\"FeaturePanel\" data-audience=\"non-subscriber\" data-remove=\"true\"><\/div>\n<p>Along the way, some bright spark noticed that sites were all requesting their own copies of common libraries \u2014 things like the latest jQuery \u2014 and if there was a common CDN version of those libraries that could be used by every site, then the user wouldn\u2019t need to keep downloading the same file. They\u2019d take the hit for the first site to use the file, but then it would sit in their local browser cache and downloads could be skipped for each subsequent site. Genius!<\/p>\n<p>This is why you\u2019ll see CDN links for your favorite libraries using URLs like <code>jsdelivr.com<\/code> \u2014 they\u2019re making use of a common CDN to host the files so that their users see the performance benefits.<\/p>\n<h3>What Could Go Wrong?<\/h3>\n<p>This remains a good, practical way to work, but it does introduce a potential vector for attack. Let\u2019s imagine that it\u2019s 2012 and everyone is using the brand new jQuery 1.8. Back with the traditional way of doing things, everyone would have their own jQuery 1.8 file hosted as part of their own website on their own server.<\/p>\n<p>If you were some kind of evil actor \u2014 like some sort of jQuery-based Hamburglar \u2014 and had figured out a sneaky way to hack the library for your own evil gains, you\u2019d have to target every website individually and compromise their servers to have any impact. That\u2019s a lot of effort.<\/p>\n<p>But that\u2019s not how things are now, as everyone is using jQuery loaded from a common CDN. And when I say everyone, I don\u2019t mean hundreds of web pages. I mean millions of web pages. Suddenly that one file has become a very attractive target for our shady hacker. If they can compromise that one file, they can very quickly have code running in millions of web pages across the globe.<\/p>\n<p>It doesn\u2019t matter what that code is. It could be a prank to deface pages, it could be code to steal your passwords, it could be code to mine cryptocurrency, or it could be sneaky trackers to follow you around the web and make a marketing profile. The important thing is that the innocent file that the developer added to a page has been changed and you now have some evil JavaScript running as part of your site. That\u2019s a big problem.<\/p>\n<div><\/div>\n<h3>Enter Subresource Integrity<\/h3>\n<p>Rather than rolling back the clocks and abandoning a useful way to use code, SRI is a solution that adds a simple level of security on top. What SRI and the <code>integrity<\/code> attribute does is make sure that the file you linked into a page never changes. And if it does change, then the browser will reject it.<\/p>\n<p>Checking that code hasn\u2019t changed is a very old problem in computer science and thankfully it has some very well established solutions. SRI does a good job of adopting the simplest \u2014 file hashing.<\/p>\n<p>File hashing is the process of taking a file and running it through an algorithm that reduces it to a short string representation, known as a hash or checksum. Without getting into the weeds, the process is either repeatable or reversible, so much that if you were to give someone else a file along with the hash they\u2019d be able to run the same algorithm to check that the two match. If the file changes or the hash changes, then there\u2019s no longer a match and you know something is wrong and should distrust the file.<\/p>\n<p>When using SRI, your webpage holds the hash and the server (CDN or anywhere) holds the file. The browser downloads the file, then quickly computes to make sure that it is a match with the hash in the <code>integrity<\/code> attribute. If it matches the file is used, and if not it is blocked.<\/p>\n<h3>Trying It Out<\/h3>\n<p>If I go to <code>getbootstrap.com<\/code> today to get a CDN link to a version of Bootstrap, I\u2019m given a tag that looks like this:<\/p>\n<div>\n<pre><code><script src=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.3.1\/js\/bootstrap.min.js\" integrity=\"sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf\/nJGzIxFDsf4x0xIM+B07jRM\" crossorigin=\"anonymous\"><\/script>\n<\/code><\/pre>\n<\/div>\n<p>You can see that the <code>src<\/code> attribute is as we\u2019re used to, and the <code>integrity<\/code> attribute holds what we now know to be a hash.<\/p>\n<p>The hash is actually in two parts. The first is a prefix to declare which hashing algorithm to use. In this case, it\u2019s <code>sha384<\/code>. This is followed by a dash and then the hash itself, encoded with <code>base64<\/code>.<\/p>\n<p>You may be familiar with <code>base64<\/code> as a way of encoding inline files like images into pages. It\u2019s not a cryptographic process \u2014 it\u2019s just a fast and convenient way to encode potentially messy data in a way that translates neatly to ASCII. This is why it\u2019s used a lot on the web.<\/p>\n<p>On seeing this, the browser will download <code>bootstrap.min.js<\/code>. Before executing it, it will <code>base64<\/code> decode the hash and then use the <code>sha384<\/code> hashing algorithm to confirm that the hash matches the file it\u2019s just downloaded. If it matches, the file is executed.<\/p>\n<p>I can test this out by putting that tag in a page, and then flipping to the Network tab in my browser tools to see that the file has been loaded.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/d46e1765-8121-4548-bc94-0580d31d8b86\/1-understanding-subresource-integrity.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/1-understanding-subresource-integrity.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/d46e1765-8121-4548-bc94-0580d31d8b86\/1-understanding-subresource-integrity.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/d46e1765-8121-4548-bc94-0580d31d8b86\/1-understanding-subresource-integrity.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/d46e1765-8121-4548-bc94-0580d31d8b86\/1-understanding-subresource-integrity.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/d46e1765-8121-4548-bc94-0580d31d8b86\/1-understanding-subresource-integrity.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/1-understanding-subresource-integrity.png?w=900\" sizes=\"100vw\" alt=\"Network tab\"><\/a><figcaption>\n\t\t\t(<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/d46e1765-8121-4548-bc94-0580d31d8b86\/1-understanding-subresource-integrity.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>I can see that <code>bootstrap.min.js<\/code> (and also the jQuery file it needs) have loaded successfully.<\/p>\n<p>Let\u2019s see what would happen if I update the hash to be something I know to be incorrect.<\/p>\n<div>\n<pre><code><script src=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.3.1\/js\/bootstrap.min.js\" integrity=\"sha384-SmashingMagazineIsCoolForCats\" crossorigin=\"anonymous\"><\/script>\n<\/code><\/pre>\n<\/div>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/3a853464-ae0a-480f-a2a8-2de7ccefdb32\/2-understanding-subresource-integrity.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/2-understanding-subresource-integrity-cropped.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/a4be5b04-9f44-4ac2-89d3-dba3f92588f1\/2-understanding-subresource-integrity-cropped.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/a4be5b04-9f44-4ac2-89d3-dba3f92588f1\/2-understanding-subresource-integrity-cropped.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/a4be5b04-9f44-4ac2-89d3-dba3f92588f1\/2-understanding-subresource-integrity-cropped.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/a4be5b04-9f44-4ac2-89d3-dba3f92588f1\/2-understanding-subresource-integrity-cropped.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/2-understanding-subresource-integrity-cropped.png?w=900\" sizes=\"100vw\" alt=\"hash\"><\/a><figcaption>\n\t\t\t(<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/3a853464-ae0a-480f-a2a8-2de7ccefdb32\/2-understanding-subresource-integrity.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>As you can see, the hash that\u2019s specified in my page no longer matches the file, so the file gets blocked.<\/p>\n<h3>Using SRI In Your Own Projects<\/h3>\n<p>Having this capability for libraries on a CDN is great, and if you see the option to use an embedded file with an <code>integrity<\/code> attribute then you should definitely favor that option. But it\u2019s not limited to big projects on CDNs, you can use this yourself for your own sites.<\/p>\n<p>It\u2019s not at all far fetched to imagine a scenario where a hacker manages to get access to just a few files on your site. I think most of us have see a client, colleague or friend who has at some point had a WordPress site compromised with a load of nasty junk that they didn\u2019t even realise was there.<\/p>\n<p>SRI can protect you from this too. If you generate integrity hashes for your own files, then you can have your site reject any changes just as it would for a remotely hosted file.<\/p>\n<div><\/div>\n<h3>Generating Hashes<\/h3>\n<p>You can, as you\u2019d expect, run some commands at your computer\u2019s terminal to generate a hash for a file. This example of how to do so comes from the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Subresource_Integrity\">MDN Subresource Integrity<\/a> page:<\/p>\n<pre><code>cat FILENAME.js | openssl dgst -sha384 -binary | openssl base64 -A  \n<\/code><\/pre>\n<p>That\u2019s getting the content of <code>FILENAME.js<\/code> and passing it as input to <code>openssl<\/code> to create a digest using <code>sha384<\/code>, which is then passed as input into another <code>openssl<\/code> command to <code>base64<\/code> encode the result. Not only is that complicated and obscure, but it\u2019s also not the sort of thing you want to be doing by hand every time your JavaScript file changes.<\/p>\n<p>More usefully, you\u2019ll want to integrate this somehow into your site\u2019s build process, and as you\u2019d imagine, there are plenty of ready-made options there. The exact implementation is going to vary wildly based on your project, but here are some building blocks.<\/p>\n<p>If you use Gulp to build your sites, there\u2019s <a href=\"https:\/\/www.npmjs.com\/package\/gulp-sri\">gulp-sri<\/a> which will output a JSON file with a list of your files and their hashes. You can then make use of this in your site. For example, for a dynamically rendered site, you might create a template plugin to read that file and add the hashes to your templates where needed.<\/p>\n<p>If you\u2019re still with Gulp but have a static site (or a statically generated site) you might use <a href=\"https:\/\/www.npmjs.com\/package\/gulp-sri-hash\">gulp-sri-hash<\/a> which will actually run through your HTML pages and modify the pages to add hashes where needed, which is very handy.<\/p>\n<p>If you\u2019re using Webpack, there\u2019s <a href=\"https:\/\/www.npmjs.com\/package\/webpack-subresource-integrity\">webpage-subresource-integrity<\/a> which in true Webpack style is more complex than any human might expect it to be, but does appear to work.<\/p>\n<p>For those using the Handlebars templating engine, there appear to be <a href=\"https:\/\/www.npmjs.com\/package\/handlebars-subresource-integrity\">options available to you<\/a>, and if your build process is just basic JavaScript, there are <a href=\"https:\/\/www.npmjs.com\/package\/sri-create\">simple solutions<\/a> there too.<\/p>\n<p>If you\u2019re using a CMS like WordPress, I found <a href=\"https:\/\/en-gb.wordpress.org\/plugins\/wp-sri\/\">a plugin<\/a> that appears to make it easy, although I\u2019ve not tried it myself. Googling for your own platform of choice with SRI or Sub Resource Integrity will likely point you in the right direction.<\/p>\n<p>You essentially want to hook your hashing in <em>after<\/em> your JavaScript files have been minified and then make that hash available in some way to whatever part of your system outputs the <code><script><\/code> tags. One of the wonders of the web platform is that it\u2019s so technically diverse, but that sadly leaves me unable to give you good implementation instructions!<\/p>\n<h3>Other Things To Note<\/h3>\n<p>In this article, I\u2019ve talked a lot about JavaScript files because that\u2019s really where it makes the most sense to defend against hacking attacks. SRI also works with CSS, and so you can use it in exactly the same way there. The risk for malicious CSS is much lower, but the potential to deface a site still exists and who knows what browser bugs could also lead to CSS inadvertently exposing your site to a hacker. So it\u2019s work using SRI there too.<\/p>\n<p>Another interesting thing you can do is use a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/CSP\">Content Security Policy<\/a> to specify that any script (or styles) on your page <em>must<\/em> use SRI, and of course that SRI must validate.<\/p>\n<pre><code>Content-Security-Policy: require-sri-for script;  \n<\/code><\/pre>\n<p>This is a way to ensure that SRI is always used, which could be useful on sites worked on by multiple team members who may or may not be fully up to speed with how to do things. Again, a good place to read more about this is the always-great <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Subresource_Integrity\">MDN docs for Subresource Integrity<\/a>.<\/p>\n<p>The last thing that\u2019s worth talking about is browser support for SRI. Support in modern browsers is broad, with the main exception being Internet Explorer. Due to the backwards-compatible way the specification has been implemented, however, it\u2019s safe to use immediately. Browsers that understand the <code>integrity<\/code> attribute will use the hash and check integrity, and older browsers will just carry on as they always have and keep working. Of course, you\u2019ll not get the added protection in those older browsers, but you will in the browsers that do offer support.<\/p>\n<h3>Conclusion<\/h3>\n<p>We\u2019ve seen not only what those weird hashes in the <code>integrity<\/code> attributes do, but how we can use them to defend against certain types of attacks on our website. Of course, there\u2019s no one silver bullet that will defend our sites against every type of exploit, but Subresource Integrity is a really useful tool in the chain.<\/p>\n<p>Exploiting a security flaw is often about getting multiple small pieces to line up. <em>If A is in place, and you can make B happen, then a bug in C makes D possible.<\/em> Browser features like SRI give us a good way to tie things down just a little bit more and potentially break that chain and prevent a hacker from getting what they want. What\u2019s more, if you can integrate it into your build process or CMS, it\u2019s something you should be able to set up once and then forget about and it won\u2019t cause you day to day inconvenience.<\/p>\n<p>As such, I\u2019d really recommend taking a serious look at Subresource Integrity and implementing it on your sites if you can.<\/p>\n<div>\n  <img decoding=\"async\" src=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/logo-red-7.png\" alt=\"Smashing Editorial\"><span>(yk, il)<\/span>\n<\/div>\n<\/article>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understanding Subresource Integrity Understanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00 If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All&#8230;<a class=\"moretag\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/\"> Read the full article&#8230;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[371],"tags":[],"class_list":["post-63398","post","type-post","status-publish","format-standard","hentry","category-user-experience"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Guest Contribution\"\/>\n\t<meta name=\"keywords\" content=\"user experience\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Understanding Subresource Integrity | Design for Immersive Technologies\" \/>\n\t\t<meta property=\"og:description\" content=\"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-04-10T11:19:12+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-04-10T11:19:12+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Understanding Subresource Integrity | Design for Immersive Technologies\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#article\",\"name\":\"Understanding Subresource Integrity | Design for Immersive Technologies\",\"headline\":\"Understanding Subresource Integrity\",\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/04\\\/1-understanding-subresource-integrity.png\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#articleImage\"},\"datePublished\":\"2019-04-10T04:19:12-07:00\",\"dateModified\":\"2019-04-10T04:19:12-07:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#webpage\"},\"articleSection\":\"User Experience\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"position\":2,\"name\":\"User Experience\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#listItem\",\"name\":\"Understanding Subresource Integrity\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#listItem\",\"position\":3,\"name\":\"Understanding Subresource Integrity\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/\",\"name\":\"Guest Contribution\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Guest Contribution\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#webpage\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/\",\"name\":\"Understanding Subresource Integrity | Design for Immersive Technologies\",\"description\":\"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/04\\\/understanding-subresource-integrity\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"datePublished\":\"2019-04-10T04:19:12-07:00\",\"dateModified\":\"2019-04-10T04:19:12-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Understanding Subresource Integrity | Design for Immersive Technologies","description":"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk","canonical_url":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/","robots":"max-image-preview:large","keywords":"user experience","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#article","name":"Understanding Subresource Integrity | Design for Immersive Technologies","headline":"Understanding Subresource Integrity","author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/04\/1-understanding-subresource-integrity.png","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#articleImage"},"datePublished":"2019-04-10T04:19:12-07:00","dateModified":"2019-04-10T04:19:12-07:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#webpage"},"isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#webpage"},"articleSection":"User Experience"},{"@type":"BreadcrumbList","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.taterboy.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","position":2,"name":"User Experience","item":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#listItem","name":"Understanding Subresource Integrity"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#listItem","position":3,"name":"Understanding Subresource Integrity","previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}}]},{"@type":"Organization","@id":"https:\/\/www.taterboy.com\/blog\/#organization","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","url":"https:\/\/www.taterboy.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author","url":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/","name":"Guest Contribution","image":{"@type":"ImageObject","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g","width":96,"height":96,"caption":"Guest Contribution"}},{"@type":"WebPage","@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#webpage","url":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/","name":"Understanding Subresource Integrity | Design for Immersive Technologies","description":"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/#breadcrumblist"},"author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"creator":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"datePublished":"2019-04-10T04:19:12-07:00","dateModified":"2019-04-10T04:19:12-07:00"},{"@type":"WebSite","@id":"https:\/\/www.taterboy.com\/blog\/#website","url":"https:\/\/www.taterboy.com\/blog\/","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","og:type":"article","og:title":"Understanding Subresource Integrity | Design for Immersive Technologies","og:description":"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk","og:url":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/","article:published_time":"2019-04-10T11:19:12+00:00","article:modified_time":"2019-04-10T11:19:12+00:00","twitter:card":"summary","twitter:title":"Understanding Subresource Integrity | Design for Immersive Technologies","twitter:description":"Understanding Subresource IntegrityUnderstanding Subresource Integrity Drew McLellan 2019-04-09T12:30:59+02:002019-04-10T11:05:32+00:00If you\u2019ve ever used a CDN-hosted version of a JavaScript library, you may have noticed a strange looking integrity attribute on the script tag. This attribute contains seemingly endless alphanumeric junk that you may be tempted to strip out in the quest for cleaner code. All that junk"},"aioseo_meta_data":{"post_id":"63398","title":null,"description":null,"keywords":null,"keyphrases":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_custom_image_width":null,"og_custom_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"created":"2021-02-07 21:04:15","updated":"2026-09-01 08:24:31","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"twitter_image_url":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/\" title=\"User Experience\">User Experience<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUnderstanding Subresource Integrity\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.taterboy.com\/blog"},{"label":"User Experience","link":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/"},{"label":"Understanding Subresource Integrity","link":"https:\/\/www.taterboy.com\/blog\/2019\/04\/understanding-subresource-integrity\/"}],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8wzr5-guy","jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/63398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/comments?post=63398"}],"version-history":[{"count":0,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/63398\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media?parent=63398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/categories?post=63398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/tags?post=63398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}