DEV Community

Cover image for Source Maps
Ganesh Shinde
Ganesh Shinde

Posted on

1 1

Source Maps

One of the easiest and effective performance wins you can gain for your website is to combine and compress your JavaScript and CSS files. But it will be really difficult and frustrating to debug the code within those compressed files. There is a solution for this and it goes by the name of source maps.

A source map provides a way of mapping code within a compressed file back to it’s original position in a source file. This means with the help of a bit of software, you can easily debug your applications even after your assets have been optimized. Most of the browsers (Chrome, Firefox, etc.) developer tools comes with built-in support for source maps.

Original main.css

body {
  background-color: rgb(27, 150, 199);
  color: white;
}
Enter fullscreen mode Exit fullscreen mode

Optimized main.min.css

body{background-color:#1b96c7;color:#fff}
/*# sourceMappingURL=main.min.css.map */
Enter fullscreen mode Exit fullscreen mode

Source map main.min.css.map

{"version":3,"sources":["custom/main.scss"],"names":[],"mappings":"AAEA,KACE,wBAAmC,CACnC,UAJgB","file":"main.min.css","sourcesContent":["$font-color: white;\r\n\r\nbody {\r\n  background-color: rgb(27, 150, 199);\r\n  color: $font-color;\r\n}\r\n"]}
Enter fullscreen mode Exit fullscreen mode

There are plenty of free plugins are available to optimize styles, scripts and create source maps for them.
Optimize styles
Optimize Scripts
Create Sourcemaps

Source maps allows developers to maintain a straight-forward debugging environment while at the same time optimizing their sites for performance.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay