Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

Reactive UI in 10 lines of code

posted in JavaScript on 2024-02-11   javascript react proxy

Reactivity became de-factor a standard in the last couple of years. All the major frameworks have some reactivity model implemented. One of the biggest even has the name React. In this article, we'll see how to write a simple reactive UI with just a few lines of JavaScript.

read more

Write your own progress indicator with vanilla JavaScript

posted in JavaScript on 2023-09-16   JavaScript Node progress

Many moons ago, I was writing a lot of Flash applications. One thing was typical, and that was a progress indication of something that we were downloading. The loaded bytes of the Flash file (.swf) itself and later of some other resource the application needs. Once I started writing everything in JavaScript, this feature disappeared. In this post, we'll see how to implement it with vanilla JavaScript.

read more

I've made an Express.js based source viewer

posted in JavaScript on 2023-08-07   JavaScript Express source viewer

It's unsurprising that we all use Express.js when we need a web server. In this article, I'll show you how I built a source viewer. It's distributed as a npm package view-source and it could render the content of a directory in a nice tree-view style.

read more

q2m - a library for translating URL params to MongoDB query

posted in JavaScript on 2023-07-03   JavaScript MongoDB query

I'm not open-sourcing very often anymore, but recently I finished developing a small tool called q2m that I believe is worth sharing. It's a library designed to convert URL parameters into MongoDB queries, which I needed for my latest project, a little SaaS called Lumina CMS.

read more

AI driven open source library for measuring your web page carbon footprint

posted in JavaScript on 2023-01-14   JavaScript AI OS

Some people say that 2023 will be the year of AI. With tools like ChatGPT and DALL·E the world is definitely changing. There are different opinions on how such instruments will affect the everyday tasks of the professionals. My two cents (for now) are that those are just tools to achieve what we want quicker and more efficiently. Who knows, someday I may call myself a "prompt engineer". For the time being, though, I'm still writing a lot of stuff alone and occasionally ask ChatGPT for help.

read more

Anchor links pointing to a fragment fires History API's "popstate" event

posted in JavaScript on 2022-11-15   history popstate anchor javascript

I hit an interesting "bug" while working on a SPA application. Clicking an anchor link that points to a fragment on the page fires the History API's popstate event. This triggers some logic on my end, which was not my intent. I fixed that with a bit of JavaScript, and I had to share the snippet.

read more

Using web dev skills to test web dev skills

posted in JavaScript on 2022-10-30   javascript quiz exercise test

Last year or so, I worked on a platform where I would publish video courses. The first one is on web fundamentals (in Bulgarian), and it's almost ready. You can check it out here. But this article is not about that. It's about a platform feature I built - an in-house validator to exercise the gained HTML, CSS, and JavaScript knowledge. After each lesson, I give a task to the students, and they can work on it right in the browser. The small application became an inspiration for another project - iloveweb.dev. So, I decided to share how the validation works.

read more

Taking Wordle to the next level (case study)

posted in JavaScript on 2022-04-04   wordle dumafun javascript

I'm sure you know what Wordle is. The game got a lot of traction a couple of months ago when The New York Times bought it. I was playing it too, so I decided to create my version in my native language (Bulgarian). This is how duma.fun was born (in Bulgarian duma means word). And as usually happens with my "little" experiments, I didn't stop at just implementing the basics. I managed to translate the initial ~300 lines of code into a three months-long project. Here's why, what, and how.

read more

The tiniest presentation framework

posted in JavaScript on 2022-03-06   presentation framework html javascript

I did roughly 50 talks over the years, and for almost all of them, I used Reveal.js. I like it because it's HTML-based. I have complete control of everything and can easily publish the slides online. However, one thing bugs me every single time - the size of my content. I want to use all the available space. This becomes very important when I'm showing code to people. That's why I wrote SimPre. It's a 10KB HTML presentation framework that properly scales and positions my content.

read more

Using JavaScript module system for state management

posted in JavaScript on 2021-03-08   javascript module state management

Hot topic last couple of years is state management. Especially in the front-end apps. There are lots of problems and lots of solutions. One thing thought is totally ignored in this context - the JavaScript module system. I'm very often reaching out to this approach and decided to share it here.

read more

Transpile to ES modules with Babel

posted in JavaScript on 2021-01-14   es babel javascript transpile typescript

While I was working on Navigo an issue popped out. It was about using the library in the context of Web Dev Server where we have everything in TypeScript. And something was not ok with Navigo. The npm package wasn't exported properly and we were keep getting a does not provide an export named 'default' error. It turned out the problem is that Navigo is not exported properly as ES module (also known as ESM).

read more

What the heck is Google Tag Manager and what it has to do with Google Analytics

posted in JavaScript on 2020-09-13   javascript tagmanager analytics google gtm gtag

Just recently I had to do changes in Google Tag Manager at work. It's interesting how I keep forgetting how everything works. So I finally decided to sit down and write an article about these things. If nothing else I will have a good memory snapshot to remind me what is what.

read more

You Really Don't Need All That JavaScript, I Promise by Stuart Langridge

posted in JavaScript on 2020-09-12   javascript performance optimization

JavaScript is your behavior layer; the way to add interactivity to your sites, to provide a slick and delightful user experience, to make everything fast and easy and clean. But at some point everything changed: the tail started to wag the dog instead and development became JavaScript-first.

read more

Recreating Facebook's Recoil library

posted in JavaScript on 2020-07-12   recoil facebook state management mycoil facebook s recoil counter atoms atom component library formattedcountervalue selector key function javascript subscribers hook const return

This weekend I decided to play with the new kid on the block - Facebook's Recoil library for managing state. I did the trivial counter example to see how it works. It's pretty simple idea so I wondered how much it takes to replicate its features. I found the exact answer - 70 lines of code. Obviously, my implementation didn't cover everything but it was fun so I decided to share my findings.

(A side note: I did not look at the code of Recoil. I didn't want to be bias on how to write my version.)

read more

Pairify - how to match balanced string pairs

posted in JavaScript on 2020-03-11   pairify balanced matches javascript pairs decided type stack line starter token code const position function category https

I'm now actively working on a VSCode extension. I started it as a theme but then decided to add some more features. Like for example a tin line on the left side of the editor marking the current function scope. In order to do that I had to analyze the current file's code and find the lines that are included in that scope. The obvious approach will be to translate the code to AST and then traverse the tree finding the information that I need. This however will require the usage of a language server which now I don't want to deal with. So I decided to explore a brute force approach. Looping over the string characters and finding balanced matches. I quickly wrapped it into a library. I called it Pairify. It consumes text and returns an array of pairs. This blog post will show you how it works.

read more

From 0 to 100 GitHub stars in a week

posted in JavaScript on 2020-02-27   github stars project branding promote octomments krasimir write idea https github blog align center don t easy section add https post link javascript reddit facebook make time

2020 for me started with the release of several OS projects. Two of them reached 100 stars in a week and I was thinking that would be nice sharing my workflow. Not like it is working every time, absolutely not, but leads to some good results.

read more

Webpack/TypeScript/React starter kit as of 2020

posted in JavaScript on 2020-02-23   webpack typescript starter react eslint beginning krasimir beginning npm run watch components app tsx src components app beginning https github

I just started using TypeScript. I did couple of React projects and noticed a pattern in the setup. I decided to export that to a starter kit 👉 beginning. It is based on Webpack with Babel and TypeScript loader.

read more

VSCode go to definition/implementation fixed

posted in JavaScript on 2020-01-17   vscode typescript intellisense problem implementation working common fixed definition

I just spent ~2 hours on this and I had to blog about it. I bet I will come back to the same problem and it will be nice to have a quick solution at hand. And the problem that I'm talking about is the non working Go to definition or Go to implementation feature of VSCode. Or in other words the JavaScript IntelliSense was not working for me. Of course it was annoying because I had to navigate to files manually via the folder tree on the left or typing the name of the file in the Cmd+Shift+P popup.

read more

Running Prettier for specific Git branch

posted in Architecture on 2020-01-14   prettier git bash script branch file awk print echo file awk run prettier line column file mode files project

I'm working on a project in my own git branch. At the end of my working day I want to do one thing - run Prettier so my code is nicely formatted before I submit the PR for code review. Of course I know about the VSCode Prettier extension but right now my editor is kinda broken and I don't want to mess with it. I'm still on my branch and I run Prettier from the terminal. All good but the amount of changes that happened is so big that my 50+ loc updates are like a needle in a haystack. It is like that because apparently there are already malformatted files in the project. It is definitely not possible to understand what I did because of so much noise. So ... I want to run Prettier but only on the files that I touched in that particular branch.

read more

AST fun. Remove a function call from your bundle

posted in JavaScript on 2020-01-13   javascript ast bundle object property path callee javascript esprima node const type

I'm working on a small library that has a logger. I'm bundling the app to a single file and I want to disable the logger for the production version. In this blog post we will see how I removed the logger.log calls from my bundle using AST (abstract syntax tree).

read more

Hopa - zero config CLI that runs JavaScript and TypeScript

posted in JavaScript on 2020-01-12   hopa runner typescript javascript babel typescript io webpack https code don t krasimir hopa

Yesterday was one of those days. I stumbled a task and wanted to find the right tool for it. That same task is on my way at least twice a week and I always refuse to optimize it. Because it was a weekend I decided to spend some time and research a proper tool for the job. Well, I find nothing that suites my need. I time-boxed a hour and said F.ck it!. I will code it myself. That's how Hopa was born - a zero config CLI that runs JavaScript and TypeScript. Transpiles, bundles, watches and executes code.

read more

Part 1: We need channels! A gentle introduction to communicating sequential processes.

posted in Riew on 2020-01-06   riew csp routine go javascript channels put javascript fibonacci index function return pattern fibonacci number

CSP is a formal language for describing patterns of interaction in concurrent systems. It's used in Go, Crystal, Clojure's core.async and a couple of other places. The idea in its core is nothing so complicated but it offers some interesting capabilities. Surprisingly enough it is not really popular in JavaScript. Recently I'm exploring this pattern and here are my findings.

read more

Part 2: Riew - reactive view basics

posted in Riew on 2020-01-06   riew csp routine go javascript channels channels channel const javascript function ch view console log

Riew is a library based on communicating sequential processes (CSP). It is made to help with communication and synchronization between your view and business logic. It's distributed as a npm package, it has 0 dependencies and adds ~8KBs (gzip) to your application on production.

read more

Part 3: Riew - reactive view in patterns

posted in Riew on 2020-01-06   riew csp routine go javascript channels console log yield krasimir riew https github function state const

In this article we will see some use cases of Riew. Those are patterns which I found repeating while using the library. There are other blog posts part of the same series and I will suggest checking at least this one so you get a basic understanding before jumping into the code snippets below.

read more

Reactive view - the concept

posted in Riew on 2020-01-04   riew csp routine go javascript channels kitty ch const function view https react redux

Something bugs me last couple of years. I'm using React for some time now and there is always this doubt if I'm placing the business logic on the right place. I'm trying to be pragmatic, to follow best practices and listen what the community is saying. However, I still feel that something is not ok. This blog post presents the idea of the reactive view. That is nothing new per se but I came up with this term because it fits well in my idea.

read more

Make your objects iterable

posted in JavaScript on 2019-11-01   javascript iterator skills console log javascript const lastname object react parts user method

Just recently I became a fan of the iterable protocol. I knew about it for some time now but never actually integrated it on my own. I ended up using it to provide a nice API for one of my libraries and I thought that this approach worth sharing.

read more

From PHP to Node with Zeit's lambdas and Cypress.io

posted in JavaScript on 2019-05-23   https blog cypress content zeit html javascript article articles

The first post in this blog was published on 25th of August 2008. This place was always living on a shared PHP/MySQL hosting. It was driven by a custom made PHP CMS for over 10 years. It is time to move forward and follow my actual language of choice - JavaScript. I spent some time recently migrating it to Zeit and this article is showing my process.

read more

8 Years of blogging

posted in Must-see on 2017-01-02   javascript top year years pseudo elements css visits blog convert html string practice node js

The first article on this blog is published on 22th of August 2008. It’s about a website which I saw at FWA. Eight years later I’m still publishing stuff here and because it is the beginning of a new year I decided to give you some statistics.

read more

iframe, or not, that is the question

posted in JavaScript on 2016-04-09   page widget javascript iframe div content script

One of the things that I really like at work is the fact that we spend time in research tickets. We have unknowns and we make a research to find out more information on particular topic. We then base our decisions on the results. Recently we had to decide whether to use an <iframe> for a third party widget development. I feel that the collected information may be handy to someone else so I decided to write it down here.

read more

Deep dive into client-side routing

posted in JavaScript on 2016-01-03   router javascript navigo routing

(This blog post is inspired by A modern JavaScript router in 100 lines and heavily related to Navigo router project)

If you build single page applications you probably know that one of the must-have parts is the router. The bit that knows how to tweak the content of the address bar and notifies the rest of the system for URL changes. In this article we will discuss the various aspects of the routing in the browser.

read more

Using Mocha with ES6 spec files

posted in JavaScript on 2015-12-23   mocha babel es6 package json file es5 babel preset es2015 tests test results javascript mocha reading spec files written

The new ES6 specification of JavaScript simply works better for me. It helps expressing my ideas in a shorter and cleaner way. So, I want to write ES6 everywhere. Even while I’m testing my applications.

read more

Enforce standards while submitting a pull request

posted in JavaScript on 2015-11-29   template textarea javascript bookmarklet n n template var code pull request

GitHub’s pull requests are an important part of my/our development process. That’s why I was thinking about creating a template that will enforce the standards.

read more

Usersnap - the holy grail of bug reporting

posted in Must-see on 2014-07-15   usersnap data xmlhttp json function script project client s page

The bug reporting is something very important for us. As developers, we produce code that should work everywhere. Not only on our machines. No matter how many times we test our application it often happens that it does not work properly for the client. We all know how helpful is an email with text “It does not work. Fix it ASAP!”. Usersnap is amazing tool that removes the gap between you (the developer) and the non-techy guy from the other side.

read more

"Help, I'm stuck in an event-loop" by Philip Roberts

posted in Must-see on 2014-06-22   event loop javascript philip roberts m stuck words

Us JavaScript programmers like to use words like, "event-loop", "non-blocking", "callback", "asynchronous", "single-threaded" and "concurrency". We say things like "don't block the event loop", "make sure your code runs at 60 frames-per-second", "well of course, it won't work, that function is an asynchronous callback!".

read more

Hungry for knowledge - Scotland JS 2014 talks

posted in Must-see on 2014-06-22   javascript neo uk vimeo talk web js ll code build

These are screencasts from the this year's Scotland JS conferences. It happened on 9th and 10th of May. If you are a JavaScript developer you will probably want to see the talks.

read more

Codefront.io is around the corner

posted in Must-see on 2014-04-25   developer open io front end css javascript talk speakers interesting conference linz

There are only two weeks left before the international front-end conference in Linz - Codefront.io. It's organized by the guys from WebBox and it's scheduled for 10th of May. You still have a chance to buy a ticket and listen interesting talks about our lovely Web.

read more

Book review: Getting Started with Grunt: The JavaScript Task Runner

posted in Nodejs on 2014-04-21   book grunt experience free javascript task runner helpful started

I just finishing reading Getting Started with Grunt: The JavaScript Task Runner. The same book that we (I and Packt publishing) run a contest for. You could still joint it here and win a free copy.

read more

A modern JavaScript router in 100 lines

posted in JavaScript on 2014-02-21   router javascript navigo match history node

(The router here is now placed in its own project - Navigo. There is also another article Deep dive into client-side routing which you may find interesting)

Nowadays the popular single page applications are everywhere. Having such application means that you need a solid routing mechanism. Frameworks like Emberjs are truly build on top of a Router class. I'm still not sure that this is a concept which I like, but I'm absolutely sure that AbsurdJS should have a build-in Router. And, as with everything in this little library, it should be small, simple class. Let's see how such a module may look like.

read more

AbsurdJS fundamentals

posted in JavaScript on 2013-11-11   css api color styles var function absurd absurdjs javascript

AbsurdJS became one of my favorite projects. I spent a good amount of time developing it and it's getting more and more interesting. I also received some positive feedback, so I think it is time to write a bit more about the module and explain how it actually works and what exactly is made for.

read more

Send message from web page to chrome extension\'s background script

posted in JavaScript on 2013-08-22   script event web page document function message content script background script send

I just answer on that question in StackOverflow. I think that this is a common quetion so it worths writing about it.

read more

Web Highlights #6

posted in HTML5 on 2013-06-25   http responsive web design ve javascript make things adaptive images lot car technique solving clown car technique

Everyday I'm reading or watching something which I find helpful. Normally I bookmark those things, but at the end I have dozen of folders and subfolders which I never check. So, I decided to make such blog post where I'll share valuable things in the net.

read more

Chrome Extension: run JavaScript in the context of the current page

posted in JavaScript on 2013-06-14   script code document content run current page tab id code executescript tab id tabs executescript tab

I'm currently working on a Google Chrome extension and I need to run a JavaScript in the context of the current page. The obvious choice for such a logic is the content script. However it is not so easy, because the content script has an access only to the DOM of the current page. It can't run global functions or use global objects.

read more

Web Highlights #5

posted in HTML5 on 2013-05-30   http web design article unnecessary paints adobe device google street view code organizing javascript css paint times http www html5rocks

Everyday I'm reading or watching something which I find helpful. Normally I bookmark those things, but at the end I have dozen of folders and subfolders which I never check. So, I decided to make such blog post where I'll share valuable things in the net.

read more

Make the web faster

posted in HTML5 on 2013-03-31   faster browser applications underlying problem tune slow javascript code js profiler chrome tracing ll talk structural profiler pages chrome devtools built build

Slow JavaScript code on your pages? Chrome provides both a sampling, and a structural profiler to help you track down, isolate, and fix the underlying problem. Tune in to learn how to use both profilers, and how to improve your own workflow to build better, faster browser applications! We'll talk about chrome://tracing, the built-in JS profiler in DevTools, and much more.

read more

Tern - intelligent JavaScript editing

posted in JavaScript on 2013-03-15   javascript tern

This is Tern. Tern is a stand-alone, editor-independant JavaScript analyzer that can be used to improve the JavaScript integration of existing editors.

read more

The Breakpoint

posted in HTML5 on 2013-03-10   devtools addy osmani paul irish breakpoint ep episode ll javascript performance tooling

A bunch of useful things about our lovely browser - Chrome. Dev tools theming, console tips, editing of SASS directly inside the browser.

read more

Chrome Devevelopment Tools could be really helpful

posted in HTML5 on 2013-02-09   detecting memory leaks network performance rendering analyze network performance instrumented development platforms googledevelopers channel strongly recommend ilya grigorik nice screencast build faster javascript code

"Your browser is one of the most and best instrumented development platforms -- you may just not realize it yet. In this episode we'll take a whirlwind tour of how to analyze network performance, rendering and layout pipeline, as well as detecting memory leaks in your Javascript code, and using audits and extensions to build faster and better apps!". A nice screencast by Ilya Grigorik. I strongly recommend the subscription to GoogleDevelopers channel.

read more

What is JavaScript prototype by Angus Croll

posted in JavaScript on 2012-06-30   javascript prototype understanding javascript prototypes http javascriptweblog wordpress language http javascriptweblog javascript language http context explanations

Maybe one of the best explanations of the prototype in the context of JavaScript language.http://javascriptweblog.wordpress.com/2010/06/07/understanding-javascript-prototypes/

read more

Google I/O 2011: Learning to Love JavaScript (by Alex Russell)

posted in JavaScript on 2012-06-11   javascript

JavaScript remains one of the most popular and important programming languages in history. Web Developer and Chrome Engineer Alex Russell exposes the timeless strengths of the JavaScript language and why it is a vital part of the open web platform. Come hear what's next for the JavaScript standard and how to get the most out of the new features coming soon in V8 and Chrome.

read more

Javascript Development Workflow of 2013

posted in JavaScript on 2012-06-05   javascript development workflow

A bunch of tools to speed up and improve your javascript development workflow by Paul Irish.

read more

Speed Up Your JavaScript

posted in JavaScript on 2012-04-26   javascript 2nd edition wrox contributor author slow

As an interpreted language, JavaScript is filled with hidden performance issues that conspire to slow down your code and ruin the user experience. Learn exactly what is fast, what is slow, and what you can do to squeeze that last bit of performance out of your JavaScript code.

read more

Nicholas Zakas: Scalable JavaScript Application Architecture

posted in Architecture on 2012-04-09   javascript

Yahoo! home page engineer Nicholas Zakas, author of Professional JavaScript for Web Developers, discusses frontend architecture for complex, modular web applications with significant JavaScript elements.

read more

JavaScript object creation

posted in JavaScript on 2012-03-04   javascript discusses object creation peters discusses object keith peters discusses article keith peters operator check prototypal inheritance alternative

In this article, Keith Peters discusses object creation in JavaScript using prototypal inheritance as an alternative to the new operator. Check out here.

read more

JSConf.eu 2011

posted in JavaScript on 2011-09-11   blip tv jsconfeu http blip tv european javascript conference strongly recommend shared online s scheduled watch year happened lectures

The European JavaScript conference is really close. It's scheduled for 01 and 02 of October. I wish I could be there. I hope that the videos from the lectures will be shared online, as this happened for the last year. I strongly recommend to watch them. There are available here http://blip.tv/jsconfeu.

read more

A few things you don\'t know about JavaScript

posted in JavaScript on 2011-05-18   javascript expert javascript programmers mistakes subtle bugs common mistakes subtle avoid common mistakes javascript programming language javascript garden check called javascript garden javascript called javascript bad practices

A couple of days ago, I found very useful page about JavaScript called "JavaScript Garden". Check out here.JavaScript Garden is a growing collection of documentation about the most quirky parts of the JavaScript programming language. It gives advice to avoid common mistakes, subtle bugs, as well as performance issues and bad practices that non-expert JavaScript programmers may encounter on their endeavours into the depths of the language.

read more

FlashDevelop scripting: open file by name (part 2)

posted in ActionScript on 2011-03-29   file results script open

After a couple of days of using my script for file opening I decided to rewrite it and add more functionalities.

read more

FlashDevelop scripting: open file by text selection

posted in ActionScript on 2011-03-20   file script projectpath system path text private static string plugincore

FlashDevelop is one of the most preferred editors for the flash development. I've been also using it last few years. I found it helpful for writing JavaScript, HTML, CSS and PHP code as well. I just took a big project with over 1000 php files and it is a little bit difficult to open the right file, even by using the Project panel. That's why I decided to invest time in solving this task and found that I can write my own C# script and run it.

read more

Javascript: autocomplete country script

posted in JavaScript on 2010-12-06   field function helper ac countries var loop div script javascript

We are all filling registration forms. It's really nice when the page helps us to do that faster. The script, that I'm going to show you, is designed to be used for a country field.

read more

Javascript to Flash communication and vise versa

posted in ActionScript on 2010-08-05   area html text flash javascript

The communication between Flash and JavaScript is really important part of the web sites today. That's why I decided to share how to do it.

read more

Trace JSON object in AS3

posted in ActionScript on 2010-07-17   str description gettypeof o spaces var object information users

I'm absolutely sure that all of you are working with JSON objects. It's pretty helpful to be able to print them and find out what exactly they contain. I wrote a simple function that makes this possible.

read more

Embed fonts in all the text fields of your flash document

posted in ActionScript on 2010-02-26   jsfl script flash embed main flash_cs3_extending pdf http livedocs adobe simply ctrl r commangs run command flash commangs run jsfl embedcharactersintextfield jsfl

Very helpful solution that will save you maybe several hours. I used JSFL language and very short script to parse all the items in the library. Then for every item just embed the characters that I wanted. Get the script from here http://www.outset.ws/files/jsfl/embedCharactersInTextField.jsfl. In flash: Commangs -> Run command (or simply Ctrl+R) and point the script file.You can download the jsfl documentation from here http://livedocs.adobe.com/flash/9.0/main/flash_cs3_extending.pdf.

read more