@mattzeunert
Immutable DevTools
function calculateHolidayCost(){var t=0;t+=getFlightCost(
);t+=getHotelCost();t+=getFoodCost();debugger;return t}fu
nction getHotelCost(){return parseFloat("GBP200")}functio
n getFlightCost(){return 300}function getFoodCost(){retur
n 200}function onButtonClick(){var t=document.getElementB
yId("value");t.innerHTML=calculateHolidayCost()}
uglifyjs all.js
-o all.min.js
--source-map all.min.map
--mangle --compress
{
"version": 3,
"sources": [
"calculate-holiday-cost.js",
"get-hotel-cost.js",
...
],
"names": [
"calculateHolidayCost",
"cost",
...
],
"mappings": "AAAA,QAASA,wBACL,GAAIC,GAAO,CAMX...",
"file": "all.min.js"
}
{
"version": 3,
"sources": [...],
"names": [...],
"mappings": [
[0, 0, 0, 0],
[8, 0, 9, 9, 0],
[24, 0, 1, -5],
...
],
"file": "all.min.js"
}
function calculateHolidayCost() {
var t = 0;
return t += getFlightCost(),
t += getHotelCost(),
t += getFoodCost()
}
{
"version": 3,
"sources": [
"calculate-holiday-cost.js",
"get-hotel-cost.js",
...
],
"names": [
"calculateHolidayCost",
"cost",
...
],
"mappings": "AAAA,QAASA,wBACL,GAAIC,GAAO,CAMX...",
"file": "all.min.js"
}
DevTools can pause on
var originalSetItem = localStorage.setItem;
localStorage.setItem = function(key, value){
debugger;
return originalSetItem.call(this, key, value);
}
var originalSetItem = localStorage.setItem;
localStorage.setItem = function(key, value){
console.trace("Setting item " + key);
return originalSetItem.call(this, key, value);
}
Pause on:
Object.defineProperty(document.body, "scrollTop", {
set: function(){
debugger;
}
})
breakpoints.debugPropertySet(document.body, "scrollTop")
breakpoints.resetAllBreakpoints();
Object.defineProperty(document.body, "scrollTop", {
set: function(){
debugger;
}
})
breakpoints.debugScroll("trace");
document.body.scrollLeft = 20;
window.scrollTo(20, 20);
window.scrollBy(30, 30);
<=> WebSockets <=>
Chrome Desktop
DevTools
(Chrome Debugger Protocol)
<=> WebSockets <=>
Chrome Desktop
Chrome on Android
Node
DevTools
(Chrome Debugger Protocol)
$ node-debug test.js
<=> WebSockets <=>
Chrome Desktop
DevTools
Sublime Text
WebStorm
IntelliJ IDEA
Visual Studio Code
(Chrome Debugger Protocol)
umaar.com/dev-tips
@mattzeunert