Append crossorigin attribute to HTML elements (<img>
, <video>
, etc).
UPDATE (2019-11): To cache thrid part resouces which have CORS configured correctly, you can also write your service workers script like this (notice fetchOptions
field):
workbox.routing.registerRoute(
new RegExp("https?://cdn.jsdelivr.net/"),
new workbox.strategies.CacheFirst({
cacheName: "static-resources",
fetchOptions: {
mode: "cors",
credentials: "omit"
},
plugins: [
new workbox.expiration.Plugin({
maxAgeSeconds: oneYear
})
]
})
);
# _config.yml
filter_crossorigin:
- name: img
crossorigin: true
domains:
- unpkg.com
attrs:
- src
img.lazyload
or link[rel="stylesheet"]
).src
, data-src
, href
.