Summary
In this chapter, we’ve covered techniques to control asset and JavaScript loading more granularly.
In order to control script loading using browser built-in functionality, we can use async
and defer
attributes; we covered their effect on module scripts versus classic scripts. We also looked at using the rel
attribute on a link
element for resource hints, and what impact preconnect
, preload
, modulepreload
, and prefetch
have on resource loading.
We can leverage the Next.js Script
component’s strategy
prop to control script loading and execution beyond async
and defer
in the context of a Next.js application.
Finally, we looked at the possibility of running certain scripts off the main JavaScript thread using the Next.js Script
worker
strategy, powered by the Partytown library.
In this final chapter, we covered asset loading strategies and optimizations such as executing code off the main thread.
This brings us to the end of this book. Hopefully, you...