When do browsers download sourcemaps?

前端 未结 1 1433
悲&欢浪女
悲&欢浪女 2020-12-13 18:37

When do browsers download the sourcemap for a minified file?

I am struggling to find documentation for any browser on if/when they download a minified file\'s source

相关标签:
1条回答
  • Source Maps are downloaded and attached to the browser when you open the developer tools. Until then the browser is not aware of the sourceMap.

    There is a code reference to the Chrome's Dev tools

    https://chromium.googlesource.com/chromium/src/+/refs/tags/75.0.3770.67/third_party/blink/renderer/devtools/front_end/sdk/DebuggerModel.js

    this._sourceMapManager.setEnabled(Common.moduleSetting('jsSourceMapsEnabled').get());
    

    Short Gist of what happens in the above code is

    Once Devtools is attached the modal triggers and enables the sourceMapManager. The sourceMapManager manages the sourceMap in Chrome. Once the SourceMapManager is initialized it looks for the #sourceMapUrl downloads and attaches the map to the debugger.

    Update Note: It's not a practice to add sourcemap's to a minified file, unless the sourcemap is served from a private network. This is for various reasons security, obfuscation etc. But this is just my opinion,it varies depending on your actual requirement. For Example: If you have any error tracking tools which needs the code to be attached, then you will have to attach the sourcemap.

    0 讨论(0)
提交回复
热议问题