Browsed by
Month: February 2020

Posts

Add behavior to HTML using Alpine.js – a Todo app

Add behavior to HTML using Alpine.js – a Todo app

Sometimes I create pages with minimal interaction and amount of JavaScript – for instance, with a hamburger menu, toggle or tabs. They require simple yet repetitive JavaScript code. There are nice big components or frameworks that solve this problem (like Bootstrap, React, Vue), but the problem is their size and often a complexity to set up. Recently (in November 2019), a new library emerged – Alpine.js.

Read more
I migrated to Google Tag Manager

I migrated to Google Tag Manager

I was very disappointed when a popular Google Analytics WordPress plugin moved most of its features to a $200 / year plan. I looked for a free alternative because I had very little requirements: add the tracking code to the page and track page scroll. It’s barely a dozen lines of code using autotrack. I think I have checked all WordPress plugins that appeared after searching for “Google Analytics” and I found only ONE that met the requirement. Unfortunately, it was not compatible with Google Analytics (analytics.js code), but only with Google Tag Manager (gtm.js)…

Read More Read More

Creating an npm package

Creating an npm package

Most of my Node.js projects require some build routine. As a fan of minimalism, for simple builds I used to write short scripts operating directly on fs. In order to avoid duplication and simplify the process for future, I created a simple npm package. I described the required steps below.

Read More Read More

Convert a ViolentMonkey script to a Chrome extension

Convert a ViolentMonkey script to a Chrome extension

The script I created in Course/movie labeling solution using Firebase and ViolentMonkey worked well on one page but randomly failed to work in another. It was caused by the page’s JavaScript code which altered the behavior of XMLHttpRequest. Because I was not able to resolve it, I decided to convert my script into a Chrome extension, which would be executed in an isolated environment.

Read More Read More

Custom build script in Node.js

Custom build script in Node.js

For simple build tasks in Node.js I use a custom script. Let’s consider the following requirements:

  1. Create the dist and dist/assets folders.
  2. Concatenate several JavaScript files and save to dist/background-dist.js.
  3. Copy assets/*.png files to dist/assets/.
  4. Copy several other files.

Read More Read More