I'm deploying my website - a static site built in GatsbyJS - and my sourcemaps are by far my largest files. I have 3 sourcemap files that are ~ 3MB. Overall they make up maybe 70% of my build.
Should I deploy them to my production server?
Are sourcemaps only downloaded by users that open devtools?
Most JavaScript and CSS sources are usually minified and source maps serve as a memory map to the compressed files. It's generally a good practice to minify and combine your assets (Javascript & CSS) when deploying to production.
A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.
A Sourcemap is a file that maps from the transformed source to the original source. It is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of Sourcemaps is to aid debugging.
Considering what a source map is you just need to take into account that:
But, of course, you might need them on production mode in case you need to debug your application (on production mode, since they are not needed for debugging purposes on development mode) (See Source maps files in production - Is it safe? and Why use source maps in production?).
So, this decision is completely up to you according to your needs and requirements, having in mind the previously mentioned points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With