So full disclosure – none of these ideas were invented nor introduced this past year, but many of them are still relatively new and incredibly useful so we’re shining a light on them! If you’re new to web development, lucky you for starting your career with access to all these awesome technologies built into the browser. If you’re a more seasoned developer and haven’t tried these yet – enjoy!
SVG Sprites
Instead of loading separate files for each icon, you set one or more icons with one sprite file and reference each one with a <use>
element. This speeds things up, keeps your code clean, and makes updates painless.
If you’re working on an application or website that reuses the same SVG icon for UI elements, consider using SVG sprites to reduce
Here’s a simple example of SVG sprites in action:
Step 1: Create an SVG Sprite File
This file contains multiple SVG icons grouped together. Save it as sprite.svg
.
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="icon-home" viewBox="0 0 24 24">
<path d="M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z"></path>
</symbol>
<symbol id="icon-user" viewBox="0 0 24 24">
<path d="M12 12c2.7 0 4-2.2 4-4s-1.3-4-4-4-4 1.3-4 4 1.3 4 4 4zm0 2c-3 0-9 1.5-9 4.5V20h18v-1.5c0-3-6-4.5-9-4.5z"></path>
</symbol>
</svg>
Step 2: Reference the Icons in HTML
You can now use the icons anywhere in your HTML by referencing their id
within the sprite.svg
file.
<svg class="icon">
<use xlink:href="sprite.svg#icon-home"></use>
</svg>
<svg class="icon">
<use xlink:href="sprite.svg#icon-user"></use>
</svg>
Step 3: Add Some CSS (Optional)
Style the icons to fit your design.
.icon {
width: 24px;
height: 24px;
fill: currentColor;
}
How It Works
- The
symbol
elements insprite.svg
define reusable icons. - The
use
tag pulls the desired icon from the sprite by referencing itsid
. - The
xlink:href
attribute specifies the path to the sprite file and the icon ID.
Full Example
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="icon-home" viewBox="0 0 24 24">
<path d="M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z"></path>
</symbol>
<symbol id="icon-user" viewBox="0 0 24 24">
<path d="M12 12c2.7 0 4-2.2 4-4s-1.3-4-4-4-4 1.3-4 4 1.3 4 4 4zm0 2c-3 0-9 1.5-9 4.5V20h18v-1.5c0-3-6-4.5-9-4.5z"></path>
</symbol>
</svg>
<style>
.icon {
width: 24px;
height: 24px;
fill: currentColor;
}
</style>
<svg class="icon">
<use xlink:href="sprite.svg#icon-home"></use>
</svg>
<svg class="icon">
<use xlink:href="sprite.svg#icon-user"></use>
</svg>
You get lightweight, scalable, and customizable icons that are easy to update and maintain. To learn more about SVG Sprites, check out this comprehensive guide – https://medium.com/@hayavuk/complete-guide-to-svg-sprites-7e202e215d34
Dynamic Viewport Height and Width
Traditional CSS units like vh
(viewport height) and vw
(viewport width) measure the viewport based on its initial size. This can cause problems on mobile, where the visible area changes dynamically as browser UI elements appear or disappear. For example, the address bar might shrink or expand the viewport height as you scroll, but vh
won’t adjust to reflect this.
Dynamic Viewport Units solve this by adapting to the currently visible area of the viewport:
dvh
: 1% of the dynamic viewport height.dvw
: 1% of the dynamic viewport width.
Here’s an example:
.hero {
height: 100dvh;
}
This ensures your hero section always takes up 100% of the available height, no matter how the browser’s UI shifts. No more ugly gaps or hidden content when things move around!
By using dvh and dvw, you get a layout that adjusts in real time, especially useful for mobile-first designs where every pixel counts. To learn more about dynamic units visit https://learnbricksbuilder.com/demystifying-vh-dvh-svh-and-lvh-in-css/
Env Safe Area Insets
On mobile devices, different “safe zones” exist around the screen edges to avoid mandatory UI elements like navigation bars, address bars, or hardware like cameras and microphones. These safe zones ensure that content doesn’t get obscured by these features.
To handle this in CSS, you can use the env()
function with properties like safe-area-inset-top
, which dynamically adapts to the safe area of the device. Here’s an example:
.content {
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
This approach is particularly useful when designing for devices with notches, curved edges, or interactive UI elements that vary by manufacturer. With env()
, your layout automatically adjusts to fit the visible, unobstructed part of the screen, creating a seamless user experience.
If you’re working with frameworks like Tailwind or React, you can integrate these safe-area insets into your components or utilities. For more on this, check out https://medium.com/@developerr.ayush/understanding-env-safe-area-insets-in-css-from-basics-to-react-and-tailwind-a0b65811a8ab
JavaScript Classes, Imports and Modules
Modern JavaScript makes it easier than ever to write clean, modular, and reusable code, thanks to features like classes, imports, and modules. Here’s a quick overview of how they work and why they’re important:
Classes
JavaScript classes provide a cleaner way to define objects and their behavior. They act as blueprints for creating reusable components with properties and methods. A basic class might look like this:
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
greet() {
console.log(`Hi, I'm ${this.name} and I'm ${this.age} years old.`);
}
}
// Usage
const john = new Person('John', 30);
john.greet(); // Output: Hi, I'm John and I'm 30 years old.
Classes simplify working with objects and inheritance, making your code more readable and maintainable.
More info: https://www.w3schools.com/Js/js_classes.asp
Imports and Exports
To keep your code modular, JavaScript lets you split functionality across multiple files using imports and exports. This helps avoid massive, cluttered files and makes it easier to manage dependencies.
Here’s an example:
math.js
export function add(a, b) {
return a + b;
}
export const PI = 3.14159;
main.js
import { add, PI } from './math.js';
console.log(add(2, 3)); // Output: 5
console.log(PI); // Output: 3.14159
By exporting specific functions, variables, or classes, you can use them in other parts of your application with import
.
Modules
JavaScript modules are essentially self-contained files that export functionality. They make it easy to write reusable and shareable code while avoiding global namespace pollution. Modules work in both browser and server environments (like Node.js), although each has its quirks.
To use ES Modules in the browser, make sure to add type="module"
to your script tag:
<script type="module" src="main.js"></script>
Modules are a fundamental part of modern JavaScript development and are supported in most environments without extra tools.
More info: https://www.w3schools.com/Js/js_modules.asp
Import Maps
When developing with Javascript modules you may end up with very long import declarations that specify entire URLs for libraries.
To get around this problem, you can use an Import Maps JSON file to assign the full path as a variable. That way your scripts can just import modules from that variable name.
<script type="importmap">
{
"imports": {
"square": "./modules/shapes/square.js",
"circle": "https://example.com/shapes/circle.js"
}
}
</script>
import { name as squareName, draw } from "square";
import { name as circleName } from "circle";
More info: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap
Spread syntax
If you have an object like FormData
that you want to inspect but don’t know what’s in it, and don’t want to write a foreach loop over it. You can use spread syntax to make the variable spread ’em.
console.log(...FormData_variable)
I groaned and started complaining out loud I had to write a loop in the console and then found this via googling
More info: https://www.w3schools.com/howto/howto_js_spread_operator.asp
Worthy mentions
Conclusion
Object oriented approaches and powerful new helpers like spread completely change the game for writing JavaScript in 2025. They make your code more modular, which means easier debugging, cleaner organization, and better reusability. With classes, you can define behaviour and structure in a way that’s intuitive and consistent. Imports and modules allow you to split up functionality into smaller, focused files, which makes maintaining and scaling your code way less painful.