# How can I add decoding="async" attribute to all img?

**URL:** <https://talk.jekyllrb.com/t/how-can-i-add-decoding-async-attribute-to-all-img/5590>\
**Category:** Uncategorized\
**Created:** [February 2, 2021, 9:28am UTC](https://talk.jekyllrb.com/t/how-can-i-add-decoding-async-attribute-to-all-img/5590 "2021-02-02T09:28:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blog](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@blog](https://talk.jekyllrb.com/u/blog)\
**Post date:** [February 2, 2021, 9:28am UTC](https://talk.jekyllrb.com/t/how-can-i-add-decoding-async-attribute-to-all-img/5590/1 "2021-02-02T09:28:47Z")

</div>

hello,  
How can I add decoding=“async” attribute to all img? Is there a plugin or other way to do this?

example:  
`<img decoding="async" src="/img.jpg" alt="">`

---

<div class="post-metadata">

**Author:** ![fabiomux](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/fabiomux/32/2656_2.png) [@fabiomux](https://talk.jekyllrb.com/u/fabiomux)\
**Post date:** [February 2, 2021, 10:33am UTC](https://talk.jekyllrb.com/t/how-can-i-add-decoding-async-attribute-to-all-img/5590/2 "2021-02-02T10:33:23Z")

</div>

I imagine you are talking about _how to add attributes with markdown syntax_, something like that should work:

```auto
![Alt title](/img.jpg){: decoding="async"}

```

---

<div class="post-metadata">

**Author:** ![blog](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@blog](https://talk.jekyllrb.com/u/blog)\
**Post date:** [February 2, 2021, 10:57am UTC](https://talk.jekyllrb.com/t/how-can-i-add-decoding-async-attribute-to-all-img/5590/3 "2021-02-02T10:57:50Z")

</div>

thx, but I meant a way to insert it automatically, like the `loading=lazy` attribute in the plugin [jekyll-loading-lazy](https://github.com/gildesmarais/jekyll-loading-lazy)

---

<div class="post-metadata">

**Author:** ![fabiomux](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/fabiomux/32/2656_2.png) [@fabiomux](https://talk.jekyllrb.com/u/fabiomux)\
**Post date:** [February 2, 2021, 1:45pm UTC](https://talk.jekyllrb.com/t/how-can-i-add-decoding-async-attribute-to-all-img/5590/4 "2021-02-02T13:45:03Z")

</div>

Well if that plugin is working for you, just rework it…

1. copy and paste the file _lib/jekyll-loadling-lazy.rb_ file under your _\_plugins_ folder;
2. load it in your config.yml file and remove any reference of the gem from your Gemfile (if you was using it as gem);
3. append after the line (or simply comment it if you don’t need the lazy loading attribute):

```ruby
 tags.each { |tag| tag["loading"] = "lazy" unless tag["loading"] }

```

this one:

```ruby
 tags.each { |tag| tag["decoding"] = "async" unless tag["decoding"] }

```

it should work!
