console.time(‘myTimer’); // Your code here console.timeEnd(‘myTimer’); // Outputs the time taken article
Category: 2025
Quick Positioning with inset in CSS
/* Verbose way */ div { position: absolute; top: 0; left: 0; bottom: 0; right: 0; } /* With inset */ div { position: absolute; inset: 0; } article
Hiding DOM Elements with Ease
<p hidden>I’m invisible!</p> No need to rely solely on JavaScript to hide elements. Utilize the native HTML hidden attribute. This has a similar effect to display: none; in CSS, making the element disappear. article
Checking Network Speed
if (navigator.connection) { const downlink = navigator.connection.downlink; console.log(`Current download speed: ${downlink} Mbps`); } else { console.log(“Network Information API not supported”); } article
Preventing Text Pasting
<input type=”text”></input> <script> const input = document.querySelector(‘input’); input.addEventListener(“paste”, function(e){ e.preventDefault() }) </script> article