DEV Community

Cover image for Gnarly Learnings from May 2023
Ethan Fertsch for The Gnar Company

Posted on • Updated on • Originally published at thegnar.com

Gnarly Learnings from May 2023

At The Gnar we are always reading, watching, and listening in order to keep our skills sharp and our perspectives fresh. Here are some of the resources we learned from this month.

Automatic Fetch Request Deduping with Next.js

NextJS focuses a lot on optimization. So it was no surprise to learn about fetch request deduping. When using fetch with Next, any GET requests with the same input will be cached, so that if there are multiple requests for the same resource during a render cycle or between page refreshes, Next will not make the HTTP request again.

Variable Fonts in Google Fonts

I am always deliberating over which and how many font weights and variants to import from Google Fonts. I want them all, but am I willing to accept the file size overhead? Luckily Google has come up with a significant improvement to web fonts: variable fonts. These fonts allow for a single font to be selected, and that font can be adjusted by weight, slant, and more. Read more about variable fonts.

Active Record’s rewhere

It now takes two hands to count the number of years I have been working with Ruby on Rails and I still regularly discover new concepts and methods. This month, it was rewhere, an Active Record method that allows you to change a previously set where condition for an attribute. If you’re thinking “Hey…that sounds an awful lot like the behavior of unscope” you’d be right! That’s because it is a shorthand for unscope(where: conditions.keys).where(conditions).

Cross-Browser Support for Import Maps

A modern choice for including and reusing JavaScript code in web apps is ES modules. There are a variety of ways to implement ES modules but import maps have been gaining popularity in recent years. Popularity, in this case, equates to industry adoption. For example, Rails 7 (released in 2021) allowed us to break away from the Node.js and webpack bundling strategy and leverage import maps instead. Now, import maps are compatible across the three major browser engines which will make developing with them much easier.

Migration Method: create_join_table

I was late to this party! When creating a join table in Rails, there's no need to pass id: false to a typical table creation method. Instead, just reach for create_join_table.

Contributors:

Learn more about how The Gnar builds software.

Top comments (0)