The One-Line Browser Trick That Makes Any Page Editable
Type document.designMode = "on" in the console and the entire page becomes editable like a document. Absurdly useful for copy reviews, screenshots and layout testing.
Software Engineer
I build web applications and share what I learn along the way.
Step-by-step programming tutorials on PHP, JavaScript, Laravel, WordPress and more.
You do not need moment.js or dayjs to print "yesterday" or "in 3 weeks". The Intl API does relative time, in the user's own language, with zero dependencies.
Type document.designMode = "on" in the console and the entire page becomes editable like a document. Absurdly useful for copy reviews, screenshots and layout testing.
Ctrl+V with an image on the clipboard fires a paste event carrying a real File object. Ten lines of code turn any form into a screenshot-friendly uploader.
Checking window.innerWidth on every resize event is wasteful and drifts out of sync with your CSS. matchMedia gives JavaScript the same breakpoints CSS uses, with change events.
Style a form field wrapper based on the input inside it, a card based on whether it has an image, a layout based on its content - all in pure CSS with :has().
A swipeable, momentum-friendly, accessible carousel needs no JavaScript at all. scroll-snap turns a plain overflow container into one, and it feels native because it is.
fetch() calls fired when a user closes the tab often never leave the browser. navigator.sendBeacon() exists precisely for this moment, and it is a one-line change.
Stop writing a font-size media query for every breakpoint. clamp() scales type smoothly with the viewport between a floor and a ceiling you control.
List bullets and text-highlight colors are both fully styleable with dedicated pseudo-elements - no list-style: none rebuilds, no browser defaults clashing with your brand.
Analytics batching, prefetching, cache warming - none of it should compete with user interaction. requestIdleCallback runs your low-priority work in the gaps.
Custom checkbox hacks - hidden inputs, pseudo-element ticks, sprite images - solved a problem that accent-color now handles in a single declaration.
Designers hate focus rings on click, keyboard users need them to navigate at all. :focus-visible gives each group what they want - and browsers already use it by default.
Grouping an array of objects used to mean writing the same reduce() dance in every project. JavaScript finally does it natively, and the syntax is one line.