Nextcloud and Kubernetes in the Cloud With Kuma Service Mesh

I recently decided I wanted to start cutting third-party cloud services out of my life. I purchased a shiny Raspberry Pi 400 (which reminded me of the Amiga computers of my youth) and decided to try Nextcloud on it as a personal cloud. It was a far quicker process than I expected thanks to the awesome NextCloudPi project. Within twenty minutes, I had a running Nextcloud instance. However, I could only access it locally on my internal network, and accessing it externally is complicated if you don’t have a static IP address, or use dynamic DNS on a router that supports it.

There are of course myriad ways to solve these problems (and NextCloudPi offers convenient solutions to many of them), but I was also interested in how Kubernetes might handle some of the work for me. Of course, this can mean I am using cloud providers of a different kind, but I would have portability, and with a combination of an Ingress and Service Mesh, could move my hosting around as I wanted.

Getting to Know Our Digital Identities With Kaliya Young [Podcast]

Are you in charge of your own digital identity? How do you share "verifiable" information about yourself on the internet?

Our guest for today sheds light on the modern world’s approach to digital identity, as we talk about the different domains of identity, how our identities are currently held and managed by corporations, civil society, and governments, and why we should advocate for the rights of our digital selves.

Managing Your Data Lifecycle With Time to Live Tables

Your organization is growing with each passing day; so is your data. More data brings more business opportunities, but it also begets higher storage costs. Do you want a better way to manage the cost? We want the same thing for our open source database, TiDB.

TiDB is a distributed SQL database designed for massive data. Our goal is to support large-scale datasets at a reasonable cost. At TiDB Hackathon 2020, we took a big step in that direction. We introduced a feature, the time to live (TTL) table, that enables TiDB to automatically manage the lifecycle of data according to its lifetime. TiDB makes sure every portion of its resources is consumed by high-value, fresh data.

Worldwide WordPress Virtual 5K Set for October 1-30, 2021

Automattic is organizing its 2nd annual Worldwide WordPress 5K during the month of October this year. Registration for the race is free and participants will have the opportunity to donate to a charity of their choice, with Automattic matching donations up to $50,000.

Just like the first Worldwide WP 5K that was held in 2015, the race will be virtual. Anyone is welcome to run, walk, bike, or swim the 5K any time between October 1-31. The requirements are fairly loose in that you can use any exercise app to track your run if you want. Participants are also encouraged to share a selfie, a screenshot of your route, and write a blog post that includes the #wwwp5k tag. Automattic will use the hashtag to include pictures on the official race site.

Throughout the pandemic, much of the social running industry has gone online and virtual races have become more common. Although they don’t carry the same energy as in-person races, virtual races help friends keep setting fitness goals and encourage each other through online challenges. Joining in the Worldwide WordPress 5K is a great way to connect with friends around the world for an offline challenge that benefits your health.

There is plenty of time to start training to reach a goal ahead of October and lots of resources available for running your first 5K. If all other motivations fail, maybe Wapuu can get you off the couch. The lack of in-person WordCamps has left some people hankering for new WordPress swag, and the 5K wapuu is ready to deliver. Participants can choose from a wide array of official gear, including hoodies, t-shirts, water bottles, tank tops, pins, socks, and more. Those who prefer not to run but still want to take part in the charitable event can give directly through the donation page.

AWS Lambdas: Easy, Easier, Easiest

I’d say cloud functions are one of the most transformative technologies in the last bunch of years. They are (usually) cheap, scale well, secure in their inherit isolation, and often written in JavaScript—comfortable territory for front-end developers. Nearly every cloud provider offers them, but AWS Lambda was the OG and remains the leader.

But also: The DX around cloud functions is just as interesting to watch as the tech behind the functions themselves. There is all sorts of tech that has sprung up around them to make them easy to use and relatively transparent. Emrah Samdan wrote that it’s a win-win for both customers and companies.

Two of the most popular Jamstack hosting platforms, Netlify and Vercel, offer idiot-proof wrappers for AWS Lambda deployments, each more developer-friendly than the next.

Joey Anuff, “AWS Lambdas: Easy, Easier, Easiest”

AWS’ own Amplify is a front-runner for easiness as well, which is in stark contrast to trying to manage your functions right through the AWS console itself.

Joey found Vercel to be easiest by a narrow margin, with the caveat that he was already using Next.js which is from Vercel.

My favorite bit here is that in the research repo for this article, Joey listed in great detail (with action GIFs) the steps for each of the services cloud functions offerings.

Direct Link to ArticlePermalink


The post AWS Lambdas: Easy, Easier, Easiest appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Mulesoft Dataweave: filter vs takeWhile

filter Vs takeWhile

Both of these functions can be used for selecting elements from the array for a given condition, The difference is "filter" returns all the element which matches condition but 'takeWhile' returns all the elements till the first failure. 

JSON
 
input :
[
    {
        "id": "100",
        "name": "Dataweave by"
    },
    {
        "id": "100",
        "name": "Arpan"
    },
    {
        "id": "200",
        "name": "Kumar"
    },
    {
        "id": "100",
        "name": "Sharma"
    }
]


=========dwl=============
%dw 2.0
import * from dw::core::Arrays
output application/json
---
{
// use 'takeWhile' when you wants to select the element till first failure of given condition.
"takeWhile" : payload takeWhile ((item) -> item.id == "100" ) ,
//use 'filter'  when you wants to select all the element for given condition.
"filter": payload filter ((item, index) -> item.id == "100")
}
=========output=============


{
  "takeWhile": [
    {
      "id": "100",
      "name": "Dataweave by"
    },
    {
      "id": "100",
      "name": "Arpan"
    }
  ],
  "filter": [
    {
      "id": "100",
      "name": "Dataweave by"
    },
    {
      "id": "100",
      "name": "Arpan"
    },
    {
      "id": "100",
      "name": "Sharma"
    }
  ]
}


Supercharging Built-In Elements With Web Components “is” Easier Than You Think

We’ve already discussed how creating web components is easier than you think, but there’s another aspect of the specification that we haven’t discussed yet and it’s a way to customize (nay, supercharge) a built-in element. It’s similar to creating fully custom or “autonomous” elements — like the <zombie-profile> element from the previous articles—but requires a few differences.

Customized built-in elements use an is attribute to tell the browser that this built-in element is no mild-mannered, glasses-wearing element from Kansas, but is, in fact, the faster than a speeding bullet, ready to save the world, element from planet Web Component. (No offense intended, Kansans. You’re super too.)

Supercharging a mild-mannered element not only gives us the benefits of the element’s formatting, syntax, and built-in features, but we also get an element that search engines and screen readers already know how to interpret. The screen reader has to guess what’s going on in a <my-func> element, but has some idea of what’s happening in a <nav is="my-func"> element. (If you have func, please, for the love of all that is good, don’t put it in an element. Think of the children.)

It’s important to note here that Safari (and a handful of more niche browsers) only support autonomous elements and not these customized built-in elements. We’ll discuss polyfills for that later.

Until we get the hang of this, let’s start by rewriting the <apocalyptic-warning> element we created back in our first article as a customized built-in element. (The code is also available in the CodePen demo.)

The changes are actually fairly simple. Instead of extending the generic HTMLElement, we’ll extend a specific element, in this case the <div> element which has the class HTMLDivElement. We’ll also add a third argument to the customElements.defines function: {extends: 'div'}.

customElements.define(
  "apocalyptic-warning",
  class ApocalypseWarning extends HTMLDivElement {
    constructor() {
      super();
      let warning = document.getElementById("warningtemplate");
      let mywarning = warning.content;

      const shadowRoot = this.attachShadow({ mode: "open" }).appendChild(
        mywarning.cloneNode(true)
      );
    }
  },
  { extends: "div" }
);

Lastly, we’ll update our HTML from <apocalyptic-warning> tags to <div> tags that include an is attribute set to “apocalyptic-warning” like this:

<div is="apocalyptic-warning">
  <span slot="whats-coming">Undead</span>
</div>

Reminder: If you’re looking at the below in Safari, you won’t see any beautiful web component goodness *shakes fist at Safari*

Only certain elements can have a shadow root attached to them. Some of this is because attaching a shadow root to, say, an <a> element or <form> element could have security implications. The list of available elements is mostly layout elements, such as <article>, <section>, <aside>, <main>, <header>, <div>, <nav>, and <footer>, plus text-related elements like <p>, <span>, <blockquote>, and <h1><h6>. Last but not least, we also get the body element and any valid autonomous custom element.

Adding a shadow root is not the only thing we can do to create a web component. At its base, a web component is a way to bake functionality into an element and we don’t need additional markup in the shadows to do that. Let’s create an image with a built-in light box feature to illustrate the point.

We’ll take a normal <img> element and add two attributes: first, the is attribute that signifies this <img> is a customized built-in element; and a data attribute that holds the path to the larger image that we’ll show in the light box. (Since I’m using an SVG, I just used the same URL, but you could easily have a smaller raster image embedded in the site and a larger version of it in the light box.)

<img is="light-box" src="https://assets.codepen.io/1804713/ninja2.svg" data-lbsrc="https://assets.codepen.io/1804713/ninja2.svg" alt="Silent but Undeadly Zombie Ninja" />

Since we can’t do a shadow DOM for this <img>, there’s no need for a <template> element, <slot> elements, or any of those other things. We also won’t have any encapsulated styles.

So, let’s skip straight to the JavaScript:

customElements.define(
  "light-box",
  class LightBox extends HTMLImageElement {
    constructor() {
      super();
      // We’re creating a div element to use as the light box. We’ll eventually insert it just before the image in question.
      let lb = document.createElement("div");
      // Since we can’t use a shadow DOM, we can’t encapsulate our styles there. We could add these styles to the main CSS file, but they could bleed out if we do that, so I’m setting all styles for the light box div right here
      lb.style.display = "none";
      lb.style.position = "absolute";
      lb.style.height = "100vh";
      lb.style.width = "100vw";
      lb.style.top = 0;
      lb.style.left = 0;
      lb.style.background =
        "rgba(0,0,0, 0.7) url(" + this.dataset.lbsrc + ") no-repeat center";
      lb.style.backgroundSize = "contain";

      lb.addEventListener("click", function (evt) {
        // We’ll close our light box by clicking on it
        this.style.display = "none";
      });
      this.parentNode.insertBefore(lb, this); // This inserts the light box div right before the image
      this.addEventListener("click", function (evt) {
        // Opens the light box when the image is clicked.
        lb.style.display = "block";
      });
    }
  },
  { extends: "img" }
);

Now that we know how customized built-in elements work, we need to move toward ensuring they’ll work everywhere. Yes, Safari, this stink eye is for you.

WebComponents.org has a generalized polyfill that handles both customized built-in elements and autonomous elements, but because it can handle so much, it may be a lot more than you need, particularly if all you’re looking to do is support customized built-in elements in Safari.

Since Safari supports autonomous custom elements, we can swap out the <img> with an autonomous custom element such as <lightbox-polyfill>. “This will be like two lines of code!” the author naively said to himself. Thirty-seven hours of staring at a code editor, two mental breakdowns, and a serious reevaluation of his career path later, he realized that he’d need to start typing if he wanted to write those two lines of code. It also ended up being more like sixty lines of code (but you’re probably good enough to do it in like ten lines).

The original code for the light box can mostly stand as-is (although we’ll add a new autonomous custom element shortly), but it needs a few small adjustments. Outside the definition of the custom element, we need to set a Boolean.

let customBuiltInElementsSupported = false;

Then within the LightBox constructor, we set the Boolean to true. If customized built-in elements aren’t supported, the constructor won’t run and the Boolean won’t be set to true; thus we have a direct test for whether customized built-in elements are supported.

Before we use that test to replace our customized built-in element, we need to create an autonomous custom element to be used as a polyfill, namely <lightbox-polyfill>.

customElements.define(
  "lightbox-polyfill", // We extend the general HTMLElement instead of a specific one
  class LightBoxPoly extends HTMLElement { 
    constructor() {
      super();

      // This part is the same as the customized built-in element’s constructor
      let lb = document.createElement("div");
      lb.style.display = "none";
      lb.style.position = "absolute";
      lb.style.height = "100vh";
      lb.style.width = "100vw";
      lb.style.top = 0;
      lb.style.left = 0;
      lb.style.background =
        "rgba(0,0,0, 0.7) url(" + this.dataset.lbsrc + ") no-repeat center";
      lb.style.backgroundSize = "contain";

      // Here’s where things start to diverge. We add a `shadowRoot` to the autonomous custom element because we can’t add child nodes directly to the custom element in the constructor. We could use an HTML template and slots for this, but since we only need two elements, it's easier to just create them in JavaScript.
      const shadowRoot = this.attachShadow({ mode: "open" });

      // We create an image element to display the image on the page
      let lbpimg = document.createElement("img");

      // Grab the `src` and `alt` attributes from the autonomous custom element and set them on the image
      lbpimg.setAttribute("src", this.getAttribute("src"));
      lbpimg.setAttribute("alt", this.getAttribute("alt"));

      // Add the div and the image to the `shadowRoot`
      shadowRoot.appendChild(lb);
      shadowRoot.appendChild(lbpimg);

      // Set the event listeners so that you show the div when the image is clicked, and hide the div when the div is clicked.
      lb.addEventListener("click", function (evt) {
        this.style.display = "none";
      });
      lbpimg.addEventListener("click", function (evt) {
        lb.style.display = "block";
      });
    }
  }
);

Now that we have the autonomous element ready, we need some code to replace the customized <img> element when it’s unsupported in the browser.

if (!customBuiltInElementsSupported) {
  // Select any image with the `is` attribute set to `light-box`
  let lbimgs = document.querySelectorAll('img[is="light-box"]');
  for (let i = 0; i < lbimgs.length; i++) { // Go through all light-box images
    let replacement = document.createElement("lightbox-polyfill"); // Create an autonomous custom element

    // Grab the image and div from the `shadowRoot` of the new lighbox-polyfill element and set the attributes to those originally on the customized image, and set the background on the div.
    replacement.shadowRoot.querySelector("img").setAttribute("src", lbimgs[i].getAttribute("src"));
    replacement.shadowRoot.querySelector("img").setAttribute("alt", lbimgs[i].getAttribute("alt"));
    replacement.shadowRoot.querySelector("div").style.background =
      "rgba(0,0,0, 0.7) url(" + lbimgs[i].dataset.lbsrc + ") no-repeat center";

    // Stick the new lightbox-polyfill element into the DOM just before the image we’re replacing
    lbimgs[i].parentNode.insertBefore(replacement, lbimgs[i]);
    // Remove the customized built-in image
    lbimgs[i].remove();
  }
}

So there you have it! We not only built autonomous custom elements, but customized built-in elements as well — including how to make them work in Safari. And we get all the benefits of structured, semantic HTML elements to boot including giving screen readers and search engines an idea of what these custom elements are.

Go forth and customize yon built-in elements with impunity!


The post Supercharging Built-In Elements With Web Components “is” Easier Than You Think appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Challenges of AI in the Media Industry and How Developers Are Facing It

Different industries today are adopting AI techniques to improve user experience in their own domains. AI in media has one of the most significant impacts on users with a high percentage of people resorting to media entertainment while being confined to their homes for the better part of the last two years. Subtitling, for example, has opened doors to the consumption of content from all over the globe, and has broken barriers of language that long restrained content consumption for users. As alluring and attractive as these new AI solutioning services may seem, on the backend, it has increased stakes for developers who have had to deal with a whole new list of challenges while dealing with this new technology and its limitless scope.

Understanding the Different Use Cases

As a developer, it is important to be able to understand a given business use case and decide whether pursuing the same with the help of artificial intelligence is the best approach. In the media industry, use cases like video subtitling and recommendation systems for content are appropriate to use cases that can leverage the abilities of artificial intelligence. Meanwhile, use cases like automation for managing equipment required in a studio may already have better-implemented solutions in the market that can be utilized rather than using AI. Being able to make the right call at the very beginning is a challenge for some developers.

Reducing Carbon Emissions On The Web

As is the case with many other developers, the reports over the last few years of the huge energy requirements of the web have prompted me to take a look at my own websites and see what I can do to minimize their impact. This piece will cover some of my experiences in doing this, as well as my current thoughts on optimizing websites for carbon emissions, and some practical examples of things you can do to improve your own pages.

But first, a confession: When I first heard about the environmental impact of websites, I didn’t quite believe it. After all, digital is supposed to be better for the planet, isn’t it?

I’ve been involved in various green and environmental groups for decades. In all of that time, I can’t consciously remember anyone ever discussing the possible environmental impacts of the web. The focus was always on reducing consumption and moving away from burning fossil fuels. The only time the Internet was mentioned was as a tool for communicating with one another without the need to chop down more trees, or for working without a commute.

So, when people first started talking about the Internet having similar carbon emissions to the airline industry, I was a bit skeptical.

Emissions

It can be hard to visualize the huge network of hardware that allows you to send a request for a page to a server and then receive a response back. Most of us don’t live in data centers, and the cables that carry the signals from one computer to another are often buried beneath our feet. When you can’t see a process in action, the whole thing can feel a little bit like magic — something that isn’t helped by the insistence of certain companies on adding words like “cloud” and “serverless” to their product names.

As a result of this, my view of the Internet for a long time was a little ephemeral, a sort of mirage. When I started writing this article, however, I performed a little thought experiment: How many pieces of hardware does a signal travel through from the computer I’m writing at to get outside of the house?

The answer was quite shocking: 3 cat cables, a switch, 2 powerline adapters, a router and modem, an RJ11 cable, and several meters of electrical wiring. Suddenly, that mirage was beginning to look rather more solid.

Of course, the web (any, by extension, the websites we make) does have a carbon footprint. All of the servers, routers, switches, modems, repeaters, telephone cabinets, optical-to-electrical converters, and satellite uplinks of the Internet must be built from metals extracted from the Earth, and from plastics refined from crude oil. To then provide data to the estimated 20 billion connected devices worldwide, they need to consume electricity, which also releases carbon when it is generated (even renewable electricity is not carbon neutral, although it is a lot better than fossil fuels).

Accurately measuring just what those emissions are is probably impossible — each device is different and the energy that powers them can vary over the course of a day — but we can get a rough idea by looking at typical figures for power consumption, user bases, and so on. One tool that uses this data to estimate the carbon emissions of a single page is the Website Carbon Calculator. According to it, the average page tested “produces 1.76 grams of CO2 per page view”.

If you’ve been used to thinking about the work you do as essentially harmless to the environment, this realization can be quite disheartening. The good news is that, as developers, we can do an awful lot about it.

Recommended reading: How Improving Website Performance Can Help Save The Planet

Performance And Emissions

If we remember that viewing websites uses electricity and that producing electricity releases carbon, then we’ll know that the emissions of a page must heavily depend on the amount of work that both the server and client have to perform in order to display the page. Also, the amount of data that is required for the page, and the complexity of the route it must travel through, will determine the amount of carbon released by the network itself.

For example, downloading and rendering example.com will likely consume far less electricity than Apple’s home page, and it will also be much quicker. In effect, what we are saying is that high emissions and slow page loads are just two symptoms of the same underlying causes.

It’s all very well to talk about this relationship in theory, of course, but having some real-world data to back it up would be nice. To do just that, I decided to conduct a little study. I wrote a simple command-line interface program to take a list of the 500 most popular websites on the Internet, according to MOZ, and check their home pages against both Google’s PageSpeed Insights and the Website Carbon Calculator.

Some of the checks timed out (often because the page in question simply took too long to load), but in total, I managed to collect results for over 400 pages on 14 July 2021. You can download the summary of results to examine yourself but to provide a visual indication, I have plotted them in the chart below:

As you can see, while the variation between individual websites is very high, there is a strong trend towards lower emissions from faster pages. The mean average emissions for websites with a PageSpeed score of 100 is about 1 gram of carbon, which rises to a projected almost 6 grams for websites with a score of 0. I find it slightly reassuring that, despite there being many websites with very low speeds and high emissions, most of the results are clustered in the bottom right of the chart.

Taking Action

Once we understand that much of a page’s emissions originate from poor performance, we can start taking steps to reduce them. Many of the things that contribute to a website’s emissions are beyond our control as developers. We can’t, for example, choose the devices that our users access our pages from or decide on the network infrastructure that their requests travel through, but we can take steps to improve our websites’ performance.

Performance optimization is a broad topic, and many of you reading this likely have more experience than I do, but I would like to briefly mention a few things that I have observed recently when optimizing various pages’ loading speed and carbon emissions.

Rendering Is Much Slower on Mobile

I recently reworked the design of my personal blog in order to make it a little more user-friendly. One of my hobbies is photography, and the website had previously featured a full-height header image.

While the design did a good job of showcasing my photographs, it was a complete pain to scroll past, especially when moving through pages of blog posts. I didn’t want to lose the feeling of having a photo in the header, however, and eventually settled on using it as a background for the page title.

The full-height header had been using srcset in order to make loading as fast as possible, but the images were still very big on high-resolution screens, and my longest contentful paint (LCP) time on mobile for the old design was almost 3 seconds. A big advantage of the new design was that it allowed me to make the images much smaller, which reduced the LCP time to about 1.5 seconds.

On laptops and desktops, people wouldn’t have noticed a difference, because both versions were well under a second, but on much less powerful mobile devices, it was quite dramatic. What was the effect of this change on carbon emissions? 0.31 grams per view before, 0.05 grams after. Decoding and rendering images is very resource-intensive, and this grows exponentially as the images get bigger.

The size of images isn’t the only thing that can have an impact on the time to decode; the format is important as well. Google’s Lighthouse often recommends serving images in next-generation formats to reduce the amount of data that needs to be downloaded, but new formats are often slower to decode, especially on mobile. Sending less data over the wire is better for the environment, but it is possible that consuming more energy to decode could offset that benefit. As with most things, testing is key here.

From my own testing in trying to add support for AVIF encoding to the Zola static site generator, I found that AVIF, which promises much smaller file sizes than JPG at the same quality, took orders of magnitude longer to encode; something that bunny.net’s observation that WebP outperforms AVIF by as much as 100 times supports. While doing this, the server will be consuming electricity, and I do wonder whether, for websites with low visitor counts, switching to the new format might actually end up increasing emissions and reducing performance.

Images, of course, are not the only component of modern web pages that take a long time to process. Small JavaScript files, depending on what they are doing, can take a long time to execute and the same potential pitfalls as images will apply.

Recommended reading: The Humble img Element And Core Web Vitals

Round-Trips Add Up

Another thing that can have a surprising impact on performance and emissions is where your data is coming from. Conventional wisdom has long said that serving assets such as frameworks from a central content delivery network (CDN) will improve performance because getting data from local nodes is generally faster for users than from a central server. jQuery, for example, has the option to be loaded from a CDN, and its maintainers say that this can improve performance, but real-world testing by Harry Roberts has shown that self-hosting assets is generally faster.

This has also been my experience. I recently helped a gaming website improve its performance. The website was using a fairly large CSS framework and loading all of its third-party assets via a CDN. We switched to self-hosting all assets and removed unused components from the framework.

None of the optimizations resulted in any visual changes to the website, but together they increased the Lighthouse score from 72 to 98 and reduced carbon emissions from 0.26 grams per view to 0.15.

Send Only What You Need

This leads nicely onto the subject of sending users only the data they actually need. I’ve worked on (and visited) many, many websites that are dominated by stock images of people in suits smiling at one another. There seems to be a mentality amongst certain organizations that what they do is really boring and that adding photos will somehow convince the general public otherwise.

I can sort of understand the thinking behind this because there are numerous pieces on how the amount of time people spend reading is declining. Text, we are repeatedly told, is going out of fashion; all people are interested in now are videos and interactive experiences.

From that point of view, stock photos could be seen as a useful tool to liven up pages, but eye-tracking studies show that people ignore images that aren’t relevant. When people aren’t looking at your images, the images might as well be empty space. And when every byte costs money, contributes to climate change, and slows down loading times, it would be better for everyone if they actually were.

Again, what can be said for images can be said for everything else that isn’t the page’s core content. If something isn’t contributing to a user’s experience in a meaningful way, it shouldn’t be there. I’m not for a moment advocating that we all start serving unstyled pages — some people, such as those with dyslexia, do find large blocks of text difficult to read, and other users almost certainly would find such pages boring and go elsewhere — but we should look critically at every part of our websites to consider whether they are earning their keep.

Accessibility and the Environment

Another area where performance and emissions converge is in the field of accessibility. There is a common misconception that making websites accessible involves adding aria attributes and JavaScript to a page, but often what you leave out is more important than what you put in, making an accessible website relatively lightweight and performant.

Using Standard Elements

MDN Web Docs has some very good tutorials on accessibility. In “HTML: A Good Basis for Accessibility”, they cover how the best foundation of an accessible website lies in using the correct HTML elements for the content. One of the most interesting sections of the article is where they try to recreate the functionality of a button element using a div and custom JavaScript.

This is obviously a minimal example, but I thought it would be interesting to compare the size of this button version to one using standard HTML elements. The fake button example in this case weighs around 1,403 bytes uncompressed, whereas an actual button with less JavaScript and no styling weighs 746 bytes. The div button will also be semantically meaningless and, therefore, much harder for people with screen readers to use and for bots to parse.

Recommended reading: Accessible SVGs: Perfect Patterns For Screen Reader Users

When scaled up, these sorts of things make a difference. Parsing minimal markup and JavaScript is easier for a browser, just as it is easier for developers.

On a larger scale, I was recently refactoring the HTML of a website that I work on — doing things like removing redundant title attributes and replacing divs with more semantic equivalents. The original page had a structure like the following (content removed for privacy and brevity):

<div class="container">
    <section>
        <div class="row">

            <div class="col-md-3">
                <aside>
                    <!-- Sidebar content here -->
                </aside>
            </div>

            <div class="col-md-9">
                <!-- Main content here -->
                <h4>Content piece heading</h4>
                <p>
                    Some items;<br>
                    Item 1 <br>
                    Item 2 <br>
                    Item 3 <br>
                <br>
                </p>
                <!-- More main content here -->
            </div>

        </div>
    </section>
</div>

With the full content, this weighed 34,168 bytes.

After refactoring, the structure resembled this:

<div class="container">
    <div class="row">

        <main class="col-md-9 col-md-push-3">
            <!-- Main content here -->
            <h3>Content piece heading</h3>
            <p>Some items;</p>
            <ul>
              <li>Item 1</li>
              <li>Item 2</li>
              <li>Item 3</li>
            </ul>
            <!-- More main content here -->
        </main>

        <aside class="col-md-3 col-md-pull-9">
            <!-- Sidebar content here -->
        </aside>

    </div>
</div>

It weighed 32,805 bytes.

The changes are currently ongoing, but already the markup is far more accessible according to WebAIM, Lighthouse, and manual testing. The file size has also gone down, and, when averaging the time from five profiles in Chrome, the time to parse the HTML has dropped by about 2 milliseconds.

These are obviously small changes and probably won’t make any perceptual difference to users. However, it is nice to know that every byte costs users and the environment — making a website accessible can also make it a little bit lighter as well.

Videos

Project Gutenberg’s HTML version of The Complete Works of William Shakespeare is approximately 7.4 MB uncompressed. According to Android Authority in “How Much Data Does YouTube Actually Use?”, a 360p YouTube video weighs about 5 to 7.5 MB per minute of footage and 1080p about 50 to 68. So, for the same amount of bandwidth as all of Shakespeare’s plays, you will get only about 7 seconds of high-definition video. Video is also very intensive to encode and decode, and this is probably a major contributing factor to estimates of Netflix’s carbon emissions being as high as 3.2 KG per hour.

Most videos rely on both visual and auditory components to communicate their message, and large files sizes require a certain level of connectivity. This obviously places limits on who can benefit from such content. Making video accessible is possible but far from simple, and many websites simply don’t bother.

If video was only ever treated as a form of progressive enhancement, this would perhaps not be a problem, but I have lost count of the number of times I have been searching for something on the web, and the only way to find the information I wanted was by watching a video. On YouTube, the average number of monthly users grew from 20 million in 2006 to 2 billion in 2020. Vimeo also has a continually growing user base.

Despite the huge number of visitors to video-sharing websites, many of the most popular ones do not seem to be fully compliant with accessibility legislation. In contrast to this, numerous types of assistive technologies are designed to make plain text accessible to as wide a variety of people as possible. Text is also easy to convert from one format to another, so it can be used in a number of different contexts.

As we can see from the example of Shakespeare, plain text is also incredibly space-efficient, and it has a far lower carbon footprint than any other form of human-friendly information transmitted on the web.

Video can be great, and many people learn best by watching a process in action, but it also leaves some people out and has an environmental cost. To keep our websites as lightweight and inclusive as possible, we should treat text as the primary form of communication wherever possible, and offer things such as audio and video as an extra.

Recommended Reading: Optimizing Video For Size And Quality

In Conclusion

Hopefully, this brief look at my experience in trying to make websites better for the environment has given you some ideas for things to try on your own websites. It can be quite disheartening to run a page through the Website Carbon Calculator and be told that it could be emitting hundreds of kilograms of CO2 a year. Fortunately, the sheer size of the web can amplify positive changes as well as negative ones, and even small improvements soon add up on websites with thousands of visitors a week.

Even though we are seeing things like a 25-year-old website increasing 39 times in size after a redesign, we are also seeing websites being made to use as little data as possible, and clever people are figuring out how to deliver WordPress in 7 KB. So, in order for us to reduce the carbon emissions of our websites, we need to make them faster — and that benefits everybody.

Further Reading

12 Best WordPress Automation Tools and Plugins Compared (2021)

Are you looking for the best WordPress automation tools and plugins?

By automating tasks on your WordPress website, you can save time and money while growing your website traffic and business.

In this article, we’ll share the best WordPress automation tools and plugins to help you speed up your workflows.

12 best WordPress automation tools and plugins

Why Use WordPress Automation Tools and Plugins?

When you’re running a WordPress website, there are many repetitive tasks that can take up a lot of your time.

By using WordPress automation tools and plugins, you can free up your time to spend on more productive tasks. They help to automate tasks like marketing, lead generation, social media, customer support, and much more.

For example, you can create an AI chatbot to automate basic customer support, or use an email autoresponder to welcome new subscribers.

That being said, let’s take a look at some of the best WordPress automation plugins and tools you can use to automate your WordPress site.

1. Uncanny Automator

Uncanny Automator

Uncanny Automator is the best WordPress automation plugin in the market. It lets you create powerful workflows to save time and reduce errors without writing any code.

Uncanny Automator seamlessly integrates with all the most popular WordPress plugins and third-party tools in the market. This makes it easy to set up your own custom automations in a couple of clicks.

Think of it like Zapier, but for WordPress websites.

For example, you can connect WordPress with Google Sheets, integrate Slack and WordPress, create buttons that trigger actions, and so much more.

There’s support for 70 different WordPress plugins and third-party apps to help you create endless automations and run your WordPress blog more efficiently.

You can get started with the free version of the plugin, which supports all kinds of WordPress plugins and actions.

2. Constant Contact

Constant Contact

Constant Contact is the best email marketing service for small businesses.

Constant Contact lets you stay in touch with your visitors after they leave your website. You can use it create automated email sequences to build customer relationships, sell products, and more.

Plus, it’s very easy to set up and create your own email newsletters. You can use the drag and drop email creator and bundled email templates to quickly create beautiful emails to send to your subscribers.

It also integrates with popular lead generation tools like WPForms and OptinMonster to fully automate your lead generation and follow-up process.

You can use our Constant Contact coupon code to get 20% off your monthly plan.

Alternatives: SendinBlue, HubSpot, and Drip are great alternatives for email marketing automation.

3. OptinMonster

OptinMonster

OptinMonster is the best conversion optimization software and WordPress popup plugin in the market. It lets you automate your lead generation and convert website visitors into new email subscribers and customers.

OptinMonster includes a library of high-converting templates you can use to create location based popups, announcement bars, slide-ins, gamified spin wheels, and more to capture your user’s attention.

Spin the wheel popup example

All of the templates can be fully customized with the drag and drop builder.

There are also advanced targeting features so that each campaign will display based on the rules you decide. For example, you can have popups display for visitors in a certain location, or show targeted messages for different pages on your website.

Note: You can get a free version of OptinMonster to get started.

4. WPForms

WPForms

WPForms is the best contact form plugin in the market used by over 4 million websites. It’s very beginner friendly and lets you create forms that make it easy for your visitors to get in touch with you.

The drag and drop form builder lets you quickly create a nearly endless amount of forms like contact forms, order forms, email subscription forms, survey forms, and more.

Beyond beginner-friendly form creation tools, you’ll find advanced features like conversational forms, geolocation tracking, login forms, and much more.

WPForms easily integrates with a ton of other tools and plugins so you can easily automate any action after someone fills out your form.

For example, you could automatically send the data to a Google Sheet, register new users on your membership site, get an SMS message from your form, and much more.

The free version of WPForms lets you create simple contact forms, but for the more advanced form creation features, you’ll need to update to WPForms pro.

5. Chatbot

ChatBot

Chatbot.com is the best AI chatbot software for WordPress. It lets you easily automate live chat on your website by setting up your own chatbot.

It comes with an easy to use chatbot builder and template library, so you can quickly create your own chatbot without any coding or technical skills.

The templates include different scenarios where a user might reach out to live chat, including customer support, bookings, selling products, and more.

Plus, it integrates with popular live chat software like LiveChat, so you can have a live agent jump in if the user needs extra help.

6. HubSpot

HubSpot CRM

HubSpot is one of the best CRM software for small businesses. It allows you to manage your leads better and automate aspects of your online marketing.

With HubSpot, you can easily manage your marketing, sales, and customer service together in one place. All of your customer data will be updated automatically.

You can view detailed performance reports to help you improve your sales and lead generation process.

Plus, it integrates easily with all the top email marketing and lead generation plugins and tools.

You can get access to the core features of the CRM for free, but to get even more features and advanced tools, you can upgrade to one of the paid plans.

7. TrustPulse

TrustPulse

TrustPulse is the best social proof plugin for WordPress that lets you set up automatic notifications to improve website conversions and make more sales.

TrustPulse automatically monitors activity on your site. When potential customers are close to buying something on your site, they will see a notification from other customers who have just made a purchase.

By simply displaying social proof, you’ll give your visitors a nudge to complete their purchase.

TrustPulse example

TrustPulse can be installed on any website without any code and customized to easily match your website’s design.

Plus, there are advanced targeting options so you can choose which products and pages you want your social proof notifications to display on.

For more details, see our guide on how to use FOMO to increase conversions.

8. Smash Balloon

Smash Balloon

Smash Balloon is a collection of 4 different WordPress social media plugins that let you add social feeds from Facebook, Instagram, Twitter, and YouTube to your website.

It’s the most popular social media feed plugins for WordPress, used by over 1.4 million websites.

Smash Balloon automates your website content by displaying your latest social media activity. This can save you time and keep your website content fresh, while keeping visitors engaged on your site.

Plus, it can boost your social proof by displaying your social media followers, comments, and like counts.

There are a lot of different ways you can customize how your social media feeds display.

For example, you can customize the design to match your brand, choose from a handful of pre-designed templates, and even add Instagram shoppable feeds to make more money.

Smash Balloon Instagram example

All of your feeds will be automatically updated when you post new content to your connected social media accounts.

You can choose to add individual social media feeds to WordPress, or use the Smash Balloon Social Wall plugin to display all of your social media feeds in one place.

There are also free versions of Smash Balloon available to let you try before you buy.

9. RafflePress

RafflePress

RafflePress is the best WordPress giveaway and contest plugin in the market that lets you grow your email list, traffic, and social media followers with giveaways and contests.

It has a drag and drop builder, so you can easily create successful giveaways using proven templates that will attract your visitor’s attention.

To enter your giveaway, your visitors will need to enter their email address, so you can automatically gain new email newsletter subscribers.

Plus, you can connect other tools you’re using like your WordPress form plugins, WordPress CRM, marketing automation tools, and more.

There is a free version of RafflePress available. If you want more powerful features to skyrocket and automate your growth, then you need to get RafflePress pro.

10. MonsterInsights

MonsterInsights

MonsterInsights is the best analytics solution for WordPress used by over 3 million websites.

It helps you automate tracking on your website with Google Analytics, without having to modify your tracking code. For more details, see our beginner’s guide on how to install Google Analytics in WordPress.

Plus, you can view these stats directly inside your WordPress dashboard. You’ll get a quick overview of your traffic sources, most popular pages, and more.

MonsterInsights stats

You can optimize your website to get more traffic, revenue, and email subscribers when you know this information.

MonsterInsights has a free version available, but to unlock the tool’s true power, you’ll want to upgrade to the premium version.

11. SeedProd

SeedProd

SeedProd is the best drag and drop WordPress page builder in the market used by over 1 million websites.

With SeedProd, you can create beautiful landing pages to automate things like product sales, webinar signups, newsletter subscriptions, and more.

SeedProd templates

There are built-in blocks that let you add things like countdown timers, optin forms, and more to build urgency and get your visitors to take action.

Plus, you can integrate your landing page with your email marketing service to send an automated email after they sign up.

The lite version of SeedProd lets you create simple maintenance mode pages, but for advanced page building features, smart blocks, and the library of templates, you can sign up for the pro version.

12. PushEngage

PushEngage

PushEngage is the best push notification software for WordPress. It lets you send automated push messages to your visitors after they leave your website.

You can set it up to automatically send out new blog post notifications, or use it to send custom messages.

Thank you push notification

It comes with all kinds of advanced marketing features like automatic drip campaigns, opt-in reminders, interactive messages, and more.

Your campaigns can be customized to work with your online store so you can increase revenue and reduce abandoned carts.

The level of personalization and targeting available will greatly help to improve your website conversions. For more details, see our guide on how to add web push notifications to WordPress.

We hope this article helped you find the best WordPress automation tools and plugins. You may also want to see our guide on how to get a free SSL certificate and our expert picks on the best HR payroll software for small businesses.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post 12 Best WordPress Automation Tools and Plugins Compared (2021) appeared first on WPBeginner.

How to Scale Like a Boss with Heroku Dynos

Finding your niche in the technology landscape is exciting and fulfilling at the same time. When your application or service is made available to customers, you feel that same thrill of completing some level of education, winning a game, or producing some artistic gem for others to enjoy.

But what happens when customers love your creation too much?

How to Use Social Media to Influence and Inspire Your Web Design Projects

This post is originally published on Designmodo: How to Use Social Media to Influence and Inspire Your Web Design Projects

How to Use Social Media to Influence and Inspire Your Web Design Projects

In this day and age, many of us spend our lives swiping and scrolling through our socials. And, in addition to being a constant source of information and entertainment, Instagram, Pinterest, TikTok and other social media sites can also provide …

For more information please contact Designmodo