Saransh Kataria

JSON Modules in JavaScript

JSON Modules in JavaScript

  • December 8, 2021

ES Modules were introduced in ES2015. The import and export keywords by default are only applicable to JavaScript code. But there is a new proposal to allow it to be used for JSON modules in JavaScript. It is convenient to keep some configuration inside a JSON file and import that....

How to check if a string contains emojis in JavaScript?

How to check if a string contains emojis in JavaScript?

  • December 1, 2021

If you have user-generated content in your web application, chances are you have to deal with strings containing emojis. Since emojis are stored as Unicode, chances are that we want to detect these in our code and then render them accordingly. This article discusses how we can check if a...

Writing conditionals in CSS: when/else

Writing conditionals in CSS: when/else

  • November 24, 2021

CSS already has had conditionals in the form of @media queries or @support queries to selectively apply styling to the document. But there is a new proposal called when/else which takes it to a different level. At the time of writing this post, the when proposal for when has been...

Retrieving content value of ::after or ::before in JavaScript

Retrieving content value of ::after or ::before in JavaScript

  • November 21, 2021

Let us suppose we had an HTML element which had an ::after property assigned to it. We are going to be retrieving the content value of ::after or ::before of this element using JavaScript. For the following element: If we needed a way of retrieving content value of ::after in...

How to permanently remove a file from Git history

How to permanently remove a file from Git history

  • November 12, 2021

We all make mistakes sometimes. Pushing files that contain some secrets or sensitive information to a Git repository is fairly common. And even if we revert the commit, it would still be present in the Git history of the project. In such cases, where we want to permanently remove a...

Select all text on click using CSS

Select all text on click using CSS

  • October 22, 2021

When a user has to select some text on a website, they have to drag and hold their mouse, or use double-click it. Sometimes, there are some samples that we know that the user is going to copy for sure. A use case for this can be code samples. The...

Detecting element causing CSS overflow

Detecting element causing CSS overflow

  • October 13, 2021

CSS overflows are an annoyance that keep showing up once in a while and are really hard to debug. Unwanted and unexpected scrollbars can lead to hours of inspecting the DOM to figure out what element is causing the issue and clicking random elements in the Chrome dev tools until...

Opening a Browser with DevTools Open by Default

Opening a Browser with DevTools Open by Default

  • October 10, 2021

While automating some parts of my development workflow, I was wondering if there was a way of opening a browser with DevTools open by default. This would save me a few clicks and small tweaks like this are always helpful. And it turns out that it is possible! All I...