Hello, I'm Stanko, a software engineer in Belgrade, writing mostly about JavaScript and React.

My blog setup

Few days ago I got a following message on LinkedIn.

Hi Stanko! I’m a junior front-end web developer and I recently found your amazing blog and fell in love with it. Since you don’t have any other social media, I decided to contact you trough here even if it’s not ideal. I was wonder what CMS you were using and if you could do a blog post about it ?

So here it is, post about my blog setup.


I’m not using a dynamic CMS but a static site generator called Jekyll. Static site generators take different approach to making websites.

Instead of having a database, pulling data from it and dynamically building your pages, static site generators generate all the pages only when there are changes to the site. No moving parts, just plain HTML files. This approach is more secure, makes caching much easier and boosts performance.

Smashing Magazine has a post on why static sites are awesome.

Static sites are not limited to blogs. Bigger websites are also easy to build, once you get a hold of it. There are agencies that are even doing it for client work.

Read more

React Image Filter

On the project I’m currently working on, client’s logo is displayed in two versions, black on the white background and vice versa. To make their life easier, so they don’t have to upload two assets, I suggested SVG. Alas they can’t use SVGs (kinda long story), so I just applied CSS filter: invert(1);, but…

…you guessed it - it doesn’t work in IE and Edge :(

So I started reading about SVG filters and found a way to invert a image. But it got me interested, so I kept going and made a React component for all sorts of color filters.

Play with the interactive demo.

Documenation available on GitHub and npm.


Read more

How to update npm using nvm


If you are JavaScript developer and not using nvm you might want to look at it. Node Version Manager is easy way to install, manage and work with multiple node versions.

And I recently got npm update notification, that looks like this:

npm update notification

This is image from the internet.

nvm doesn’t let you update only npm, but just a node+npm version. But there is a really easy way to do it:

# navigate to nvm's node lib folder
# (replace v8.4.0 with your version)
cd ~/.nvm/versions/node/v8.4.0/lib/

# update npm right there
npm install npm

# reopen your terminal

That’s it. Great thing is that npm can update itself. And this works for any other global npm package.

localStorage and sessionStorage in Safari's private mode

If you didn’t know, in Safari’s private mode both localStorage and sessionStorage are not working. To be exact, Safari sets storage’s limit to 0, so you can’t write anything to it. I keep forgetting this, until QA people report it at some point.

So I quickly wrote a small facade for it, which fails silently in this case. That means it still doesn’t work but it won’t throw an error and break your application.

This is the version for localStorage, just replace it with sessionStorage if you need it.

const LS_TEST_KEY = 'ls-test';
let isLocalStorageSupported = typeof localStorage === 'object';

// Try to
try {
  localStorage.setItem(LS_TEST_KEY, 'test');
} catch (e) {
  isLocalStorageSupported = false;

  // If we get error that we exceeded storage's quota
  // but storage is still empty we are in private mode
  if (e.code === DOMException.QUOTA_EXCEEDED_ERR && localStorage.length === 0) {
    // Private mode
  } else {
    throw e;

const LocalStorage = {
  getItem: (key) => {
    if (isLocalStorageSupported) {
      return localStorage.getItem(key);

    return null;

  setItem: (key, value) => {
    if (isLocalStorageSupported) {
      localStorage.setItem(key, value);

  removeItem: (key) => {
    if (isLocalStorageSupported) {

export default LocalStorage;

Get element offset in JavaScript


When we left jQuery behind and embraced modern JavaScript frameworks, we thought we would never touch DOM directly again. Well that is not entirely true. There are a lot of cases when you need to get some DOM element size. For element’s dimensions .offsetWidth and .offsetHeight are great way to do it.

But one of the other common tasks is getting element’s offset, top and left. I’ll show you two ways to get those.

Read more