I am creating posts for my plugins to make it easier to find them using the forum search and not just the docs search.
File Method and css/js helper to add cachebusting hash and optional Subresource Integrity to files.
echo Bnomei\Fingerprint::css('/assets/css/index.css');
// <style> element with https://../assets/css/index.css?v=1203291283
echo Bnomei\Fingerprint::js('/assets/js/index.min.js');
// <link> element https://../assets/js/index.min.js?v=1203291283
echo Bnomei\Fingerprint::url('/assets/css/index.css');
// raw url https://../assets/css/index.css?v=1203291283
echo $page->file('ukulele.pdf')->fingerprint();
// https://../ukulele.pdf?v=1203291283
echo $page->file('ukulele.pdf')->integrity();
// sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC
// generate sri from local file
echo Bnomei\Fingerprint::js(
'/assets/js/index.min.js',
[
"integrity" => true
]
);
/*
<script src="https://../assets/js/index.min.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
crossorigin="anonymous"></script>
*/
echo Bnomei\Fingerprint::js(
'https://external.cdn/framework.min.js',
[
"integrity" => "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
]
);
/*
<script src="https://external.cdn/framework.min.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
crossorigin="anonymous"></script>
*/