Title: Remove attributes
Last modified: August 11, 2023

---

# Remove attributes

 *  Resolved [jonte98](https://wordpress.org/support/users/jonte98/)
 * (@jonte98)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/remove-attributes/)
 * **These <img> attributes associated with the dominant color feature should be
   removed:**
    - data-dominant-color=”63646d”
    - data-has-transparency=”false”
    - data-has-transparency=”true”
 * **And inline CSS can be reduced from:**
 * `img[data-dominant-color]:not(.has-transparency) { background-color: var(--dominant-
   color); }`
 * **To this:**
 * `img:not(.has-transparency) { background-color: var(--dominant-color); }`
 * And it all adds up, especially when you have plenty of images. The less code,
   the better performance.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [jonte98](https://wordpress.org/support/users/jonte98/)
 * (@jonte98)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/remove-attributes/#post-16966905)
 * Proof of concept – this code alters exactly as above, and it works just as before
   except its less code in the DOM. The inline CSS ended up optimized a bit further.
 *     ```wp-block-code
       function img_attr_cleanup(){
       add_filter("wp_get_attachment_image_attributes",function($attributes){
   
           if (isset($attributes["data-dominant-color"])){
               unset($attributes["data-dominant-color"]);
           }
           if (isset($attributes["data-has-transparency"])){
               unset($attributes["data-has-transparency"]);
           }
   
           return $attributes;
       });
       }
       add_action("template_redirect", "img_attr_cleanup");
   
       add_action("wp_enqueue_scripts",function(){
        wp_dequeue_style("dominant-color-styles");
   
        wp_register_style('dcs',false);
        wp_enqueue_style('dcs');
        wp_add_inline_style('dcs','img:not(.has-transparency){background:var(--dominant-color)}');
   
       },20);
       ```
   
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/remove-attributes/#post-16970582)
 * Thanks for reaching out and sharing your suggestion [@jonte98](https://wordpress.org/support/users/jonte98/).
   As the plugin is open source, you’re welcome to propose any changes over the 
   [plugins GitHub repository](https://github.com/WordPress/performance/issues).
 * If you’re not comfortable making such suggestions or if you don’t have a GitHub
   account I’d be happy to create a GitHub issue on your behalf, let me know and
   I’ll do so. I’ll also share your suggestion with the team. Many thanks.
 *  Plugin Support [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * (@jamesosborne)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/remove-attributes/#post-17328629)
 * As we didn’t receive a response I’ll mark this as resolved. Feel free to open
   a new support topic if you continue to encounter issues, or reopen this topic
   and we’d be happy to assist.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Remove attributes’ is closed to new replies.

 * ![](https://ps.w.org/performance-lab/assets/icon.svg?rev=2787149)
 * [Performance Lab](https://wordpress.org/plugins/performance-lab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/performance-lab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/performance-lab/)
 * [Active Topics](https://wordpress.org/support/plugin/performance-lab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/performance-lab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/performance-lab/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [James Osborne](https://wordpress.org/support/users/jamesosborne/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/remove-attributes/#post-17328629)
 * Status: resolved