Prowadzimy rekrutację w Polsce do naszych biur w Krakowie i Tarnowie - dowiedz się więcej!

JavaScript lifehacks hints and workarounds we collected so far

There is a lot of situations where we need either to debug smth, or write JS right away inside Chrome Terminal, all nuggets from that type of situations are collected here

Missing component: content/content/introheader


We use wkhtmlpdf a lot in a bunch of projects, below are some discoveries ofc powered by searching on StackOverflow

Reminder: WKHTMLPDF ignore the media queries for print because it's actually not printing

Below some nice gems on the topic


Quickly generate Unique hash

Sometimes we need UID and this tool would help to come up with one quickly

Convert Object into array of strings

var objectEntries = Object.entries(experienceObject);
// Result is:  0: [
//   ["name", "Raymon"],
//   ["title", "Lead Frontend/JavaScript Developer"],
//   ["yearsExperience", 8],
// ]

Debug which event listener is attached to a DOM element


Will get all event listeners on the element focused in the Chrome Dev Tools currently

Scroll Page to Element

Often used to navigate to the top of the page or from table of contents to an element

el = document.getElementById('your-el-id');
var rect = el.getBoundingClientRect ();
window. scrollTo(rect.x, rect.y)

Named Console.logs

See example below

console.groupCollapsed('Product list view tracked - preview')
console. log('gtag', 'event', 'page_view', google_page_view) 
console. log ('fbq',"track","ViewContent' fb_pixel_track)

Output objects as a Table using Console.logs




Trigger click on <A> element

.click() works fine on buttons but we sometimes need to use smth similar on <a>

Below wisdom comes from - this place contains a lot more interesting and useful gems


Often we use Chat GPT to write some code snippets for us, so below are some things we were used it to help us with:

Custom variable in the className in the JSX


Vanilla JS that captures screenshot of a DOM node


Get a node of an element user right clicked on

Visit Our Office

16 Halcyon Ln
Aliso Viejo, CA 92656

Let's Talk

Phone: (415) 910-2498

call us

We are happy to listen
suggest a feature, report a bug.

Submit Feature Request