How browsers are parsing HTML script tags

The project that caused this article is React and headless architecture, a lot of API calls are returning JSONs.
We had a problem, sometimes we had white page because of a lot of JS errors.

Do you know how browsers are parsing the HTML and especially the script tags?

It is sequentially, line by line, character by character.
Look at the below HTML, what do you think will happen if you run this code?

Continue reading “How browsers are parsing HTML script tags”

The dimensions of an img tag

The other day in the team we were playing with one simple bug. The bug was why the Intersection Observer is loading almost all images on the page which are not in the viewport?

It was simple, the src attribute was empty:

<img src="" data-src="" class="lazy-load" alt="Some title" />
Continue reading “The dimensions of an img tag”

When to use browser push notifications

Push notifications are a really nice feature, you can trigger a notification to the user device with any text that you want with title, image, body and it even can make the mobile device to vibrate (depends on the browser) when receiving it.

This is a really cool way to get the user attention when you have promotions, forgotten baskets full of products or you have published something new.

Continue reading “When to use browser push notifications”

Why you should care when you are sending the notifications?

What I observe on vast of the majority of the news websites and not only them, is that they are sending all kind of notifications (Apps, Twitter, Emails etc.) when possible, 10 AM, 2 PM, 11 PM, 1 AM.

Continue reading “Why you should care when you are sending the notifications?”

How to send emails that are not marked as SPAM?

Recently I helped one company to prevent common emails for registrations and etc. to be marked as SPAM automatically from users mailboxes.

When you are using third-party service like MailChimp and with your own domain to send your emails you have to do several steps to prove all mailboxes that you are you and that you are not some spammer.

Continue reading “How to send emails that are not marked as SPAM?”

Apache – Rewrite all URIs to a single file

This week I had to help a friend with his new small ReacJS website running on Apache.

His problem was that URIs which does not exist the Apache was returning as 404 pages, he needed a common rule used by a lot of PHP frameworks, Rewrite all URIs which are not Files or Directories to /index.html

Example URL to actually load and let the ReactJS route do his work and show what it needs.

Continue reading “Apache – Rewrite all URIs to a single file”

Go Lang Oracle – ORA-00933: SQL command not properly ended

While building some migrations with Goose I had some strange (for me) error, for which you can find a lot of different stuff on Google but nothing helped.

The error was like in the title: “ORA-00933: SQL command not properly ended” for this query

UPDATE table1 SET title = CONCAT('FORMER-', title) WHERE id < = 500;

This query will work without problems in SQL editor like Oracle SQL Developer but not in the GO Goose adapter

Continue reading “Go Lang Oracle – ORA-00933: SQL command not properly ended”

PHP SoapClient() gives error 500 and cannot catch the error

Went to an error 500 in production server while using PHP SoapClient library to connect to some third-party API. The error was really strange, just error 500 and nothing more, even if you are using try catch, you won’t be able to catch and see the error.

The Example:

    $client = new SoapClient("", ['exceptions' => true, 'trace' => true]);
} catch(SoapFault $fault) {
    trigger_error("SOAP Fault: (faultcode: " . $fault->faultcode . ", faultstring: " . $fault->faultstring . ")", E_USER_ERROR);
} catch(Exception $e) {
    trigger_error("SOAP Error: " . $e->getMessage(), E_USER_ERROR);

Continue reading “PHP SoapClient() gives error 500 and cannot catch the error”