Trying to find out if the Apache server is running on macOS? How to find it? And once you find it, why are there several methods to start, stop and restart it? You may feel lost. Let’s sort this out.
Continue reading “macOS – find, start, stop, and restart the Apache web server”Resolving the script tag type attribute hash prepending issue with Cloudflare
If your script
HTML tag has the type
attribute prepended with a hash, like <script type="ea10e272b0a1989fb2f3aa4e-text/javascript">...</script>
and you’re using Cloudflare services, then the root cause is the Cloudflare Rocket Loader, a feature of Cloudflare that optimizes the loading of JavaScript resources on your web pages.
Rocket Loader modifies the type
attribute of script
tags for website loading optimization by deferring the loading of JavaScript until after rendering. This modification can sometimes cause issues with HTML validation and Content Security Policy (CSP) headers.
Cloudflare Rocket Loader adds an argument “type” into the script
tag and causing issues with the W3C validator due to the “subtype missing” error.
Get days between two dates in JavaScript
To get the number of days between two given dates, you can do that by converting them to UTC timestamps and then computing the difference in days based on the millisecond difference.
Continue reading “Get days between two dates in JavaScript”Get and capitalize the first letter of a string in JavaScript
To covert a first letter in the string to upper case we need to use toLocaleUpperCase
and taking the surrogate pairs into account.
Convert SVG to image in browser: PNG, JPEG, WebP
To convert SVG to PNG, JPG, or WebP , you can use the DOM API to create an object URL from the SVG code, load it into an image element, and then write that image to a Canvas. Finally, you can use the toDataURL()
method to convert the Canvas to a base64 encoded PNG image.
How to find the highest z-index on a page using JavaScript
To find the highest z-index
value on a page using JavaScript, you can loop through all the elements on the page and check their z-index
values. The element with the highest z-index
value will be the one that appears on top of all other elements.
Simple steps to convert a webpage into a PDF file
To save a webpage without html tags as a PDF (Portable Document Format), you can follow different methods depending on the browser or device you are using.
You don’t need to implement any JavaScript code to achieve that, but the page has to be printer-ready (implemented styles for CSS media type print).
Continue reading “Simple steps to convert a webpage into a PDF file”Add a badge to the browser tab favicon using JavaScript
Adding a badge to the favicon using JavaScript can be done by updating the image specified by the <link />
element with a new icon image.
This method involves JavaScript and creating an in-memory canvas
element, applying the favicon image, drawing the badge shape and text on top, and then updating the <link />
element’s href
attribute with the final composite of the canvas element’s image data as a Base64 encoded string.
Check if a string is valid HTML using JavaScript
Validating if a string is valid HTML can be done using DOMParser API and its method parseFromString
.
The DOMParser API interface allows you to parse XML or HTML source code from a string and convert it into a DOM Document. It is used to convert a string of XML or HTML into a structured DOM object that can be easily manipulated using JavaScript.
Continue reading “Check if a string is valid HTML using JavaScript”Optimizing Background Videos for Fast Loading: Tips and Strategies for Improved User Experience
Adding videos to your website can sometimes be a double-edged sword. Web users love high-resolution videos, but if your website isn’t optimized to handle them, such content can cause performance problems.
When it comes to optimizing background videos for fast loading, there are several steps you can take.
Continue reading “Optimizing Background Videos for Fast Loading: Tips and Strategies for Improved User Experience”