Created PrefetchLink component that is able to download resource on link hover.
Note that in case of page links it will download a js chunk based on route string matching it with routes/keys.
there's no check for resource type whether it's downloadable or not. checking against extension would be hard to implement considering variety of supported resources. see https://caniuse.com/#feat=link-rel-prefetch
links with download attribute will ignore prefetch
there is a piece of code that needs to be maintained manually - we need to name pages chunks appropriately and match with route keys. See example:
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
Did you test your solution?
Problem Description
Missing html resource hints ISSUE https://github.com/Jam3/nyg-jam3/issues/234
Solution Description
Created
PrefetchLink
component that is able to download resource on link hover. Note that in case of page links it will download ajs
chunk based on route string matching it withroutes/keys
.Side Effects, Risks, Impact
Aditional comments: IMPORTANT
pages/Pages.js
routes/keys.js
above
webpackChunkName
matches appropriate page key from routes