🔥 Laravel Tip #79: To avoid render blocking JS, consider using async or defer attributes. Use async for independent scripts that require early loading (e.g. analytics). Use defer for scripts that need the DOM or need to execute in order. Learn more:
TypeScript Tip 💡 You can use "Pick" to quickly create new types. And the cool thing is... Pick is an inbuilt utility type. We have that available natively in TypeScript.
Need to grab the second item from an array? Here are two (of many) ways to do that with destructuring! Since arrays are objects, you can use the index as a property to destructure it
Tiny little snippet - powered by @Alpine_JS - that lets you quickly convert timestamp into the browser-local representation.
⚡ Promise.allSettled With this new member of Promise, we can accept an array of Promises and only resolve when all of them are settled. Either resolved or rejected. This enables us to run all promises without caring if they're resolved or rejected.
⚡ globalThis If you want to reuse code across different runtimes, you'll run into trouble with the global object. globalThis will reference 'window' in browsers, 'global' in Node.js, and 'self' in Web Workers. Now we don't have to manually detect the runtime anymore.
💙 TypeScript tip 💙 You can tie the return type of a function to specific values provided as arguments. The keyof operator allows you to extract the keys of interfaces, objects, and more and use them to create generic types!