10
Asset Loading Strategies and Executing Code off the Main Thread
There are situations in the life cycle of an application where loading more JavaScript is inevitable. This chapter details techniques to mitigate the impact of such situations. You’ll learn about asset loading optimizations such as a script element’s async, the defer attribute, the impact of type="module", and the link element’s rel (relationship) attribute’s preconnect, preload, and prefetch values. Next, you will further optimize script loading using Next.js’ Script component and its different options. The chapter wraps up with an exploration of reasons to execute JavaScript code off the main thread and an approach to do so.
In this chapter, we’ll cover the following topics: ...
Get JavaScript Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.