error TS2792: Cannot find module ‘moment’. Did you mean to set the ‘moduleResolution’ option to ‘node’, or to add aliases to the ‘paths’ option?
Got this error when trying to import moment
into a TypeScript React (.tsx) module?
Got this error when trying to import moment
into a TypeScript React (.tsx) module?
EventSource is a handy API supported by all browsers, which runs over the regular HTTP protocol and doesn’t require setting up a separate WebSocket service. However, it has limitations, such as data being one-directional (server to client) or a connection being constantly occupied. Let’s dive in.
…Being from early JavaScript days, you might’ve been used to setting a timeout
for all your HTTP requests in jQuery or libraries like axios, request, etc. Yet to your surprise, there’s no timeout
parameter for native browser’s fetch
.
You might have had this while using the CSS columns
rule and getting rid of all those JavaScript libraries. One of the elements got suddenly cut and wraps to the next column.
Here is a simple maintenance page with a black-and-yellow construction stripe at the top.
…Simple responsive HTML/CSS maintenance page with black-and-yellow construction stripesRead More »
There’s no need to use a library to implement a nice toggle for your project. This can be done with pure CSS and completely zero JavaScript.
…Let’s chew down another issue: we have a /public folder with images, and depending on the browser we want to serve a WEBP or AVIF to save bandwidth and decrease page load time.
…Automatically serve .webp or .avif with Node.js based on browser request headers.Read More »
Here’s a small cool trick to make the whole document editable.
document.designMode = 'on';
This can also be used with iframes, i.e.
let iframeNode = document.getElementById('myeditor'); // or any other ways to get reference to an iframe
iframeNode.contentDocument.designMode = "on";
Try this out with the current page by clicking here!
Cash is an absurdly small jQuery alternative weighing only 16 KB minified, and 6 KB gzipped.
…Transition from jQuery to a slimmer alternative framework (💰 Cash)Read More »
You can convert HTML and CSS to SVG directly in a browser. With JavaScript. And JSX.
…