or how to compare dates in Javascript

Image for post
Image for post
Photo by Noel Broda on Unsplash

I stumbled upon the blog post named You Cannot Compare Dates In Javascript.
The title is a bit misleading and it doesn’t give a reason, why we can’t compare them. Maybe we should not compare Date objects directly, but we can and should compare dates with Javascript.


Image for post
Image for post

My previous story on this topic was:
How to bypass “slider CAPTCHA” with JS and Puppeteer

In this story, I will go further to solve slider captcha with a different technique. This technique will solve the slider captcha faster and more efficiently. My focus will be on GeeTest slider captcha, but you could apply it to any other similar slider captcha. I will show you how to bypass it in a few steps.

1. Get images

Let’s go to the GeeTest website. Our puppeteer script needs to wait a bit for images to load. …


Don’t just blindly change your User-Agent header.

Image for post
Image for post
Photo by Daniel Cheung on Unsplash

When scraping, we want to do a few things. Scrape slowly (but fast enough), use proxy, rotate ip address and rotate User-Agent header. With this, we may go unnoticed.

User-Agent header is one of the most abused headers by those who are scraping. And it’s all because of UA sniffing.

It’s all great if we just fetch HTML and parse it with cheerio. There is no one to check us. Now, we need to scrape a website with JS enabled, because website is doing black magic client side rendering.

We setup Puppeteer JS…


Image for post
Image for post
Photo by James Pond on Unsplash

Next story on same topic - How to solve GeeTest “slider CAPTCHA” with JS

Spam is a huge problem for website owners. On the other hand, CAPTCHAs drives me crazy and they are bad for user experience.

CAPTCHA sucks. Let’s face it. There are a lot of ways to verify humans and every method sucks.

In recent years bots are becoming smarter every day and it is hard to defend website from bots. With a lot of spare time and enough resources, we can bypass almost any CAPTCHA. There are plugins for Puppeteer to solve reCAPTCHA. There are companies that…


Parallax technique is not new. Few years ago parallax could end up implemented wrong, with jank. Now it’s 2019, browsers are great enough.

There are plenty of examples in the wild. There are also lots of libraries.
Parallax technique can be done with only CSS or with CSS+JS.

Here, I will show you how parallax is easy to implement with CSS variables and I will flavor it with just a little bit of vanilla JS.

Image for post
Image for post
Photo by Andrew DesLauriers on Unsplash

I was scrolling through some dribbble shots and I came across some really sleek parallax prototypes made by giulio_cuscito and dennissnellenberg.

Let’s build it

If you have photoshop…


Image for post
Image for post

There are so many posts about lazy loading images, I will bring nothing new to the table. But if you haven’t considered lazy loading yet, here are 3 quick and easy techniques to make web pages faster.

Why

I understand that there are websites that will have lots of images by their nature. But I can’t believe that there are websites made by tech companies that load 5MB-10MB of images, just because it’s easier / faster / cheaper to develop that way.


Image for post
Image for post
Photo by Eric Muhr on Unsplash

You searched how to tree shake with Parcel and didn’t find it. It’s quick and easy. Every ones in a while we start some project and we start importing libraries. Project start to grow more and more and then we take a look how big our bundle is, and it’s huge. We don’t want to bundle code we don’t use, right? Let’s see how we can bring it down.

TL;DR

As of parcel v1.9.0 use cli option --experimental-scope-hoisting

parcel build index.html -d build --experimental-scope-hoisting

Lodash

Although, you don’t need lodash in a first place, lodash has all those handy util functions we…


Image for post
Image for post
Web browser automation tools

You know that something is wrong when your tests are slow, unstable and ignored. Did I mention unmaintainable and hard to write? And finally how easy/hard is to setup your testing environment?

Writing tests is usually painful and boring task, but I knew we can do it better. So lets check how we can do it in JS. I started evaluating few tools in order to show power of JS. Sure, JS ecosystem is so volatile, when you finish with reading of this post, maybe new/shiny tool will popup (or not).

Puppeteer

With Puppeteer you can automate literally everything. We can…


Image for post
Image for post
Photo by Nate Grant on Unsplash

When ES6 (ES2015) standard came out, it was overwhelming to check all new cool language features and to start using them asap. Although new features were awesome, ES6 was huge step forward and browsers needed quite some time to implement them.

Now, years later, Javascript is in much better state. Javascript will continue it’s improvement and each browser has it’s on part in this process.

Looking back at 2017, I would say async/await was single most useful feature.

Now, it’s almost mid 2018, and it’s time to see what is coming in near future. So, lets check at kangax table


Image for post
Image for post

Every once in a while we need to store/persist something in a database or we need to cache some data. It can be because we want to improve performance, support offline mode or we just need feature that need web storage.

So, what are the options that we have right now:

1) Store all data on server database (SQL or NoSQL)

2) LocalStorage / SessionStorage - limited memory (around 5MB)

3) WebSQL - it has been deprecated in favor of IndexedDB

4) IndexedDB - designed as “one true” browser database with 50MB and more

tl;dr Use some library from conclusion…

Filip Vitas

Coffee Driven Software Developer @SBGenomics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store