const redundantAttributes = {
    'form': {
        'method': 'get'
    },

    'input': {
        'type': 'text'
    },

    'button': {
        'type': 'submit'
    },

    'script': {
        'language': 'javascript',
        'type': 'text/javascript',
        // Remove attribute if the function returns false
        'charset': node => {
            // The charset attribute only really makes sense on “external” SCRIPT elements:
            // http://perfectionkills.com/optimizing-html/#8_script_charset
            return node.attrs && ! node.attrs.src;
        }
    },

    'style': {
        'media': 'all',
        'type': 'text/css'
    },

    'link': {
        'media': 'all'
    }
};


/** Removes redundant attributes */
export default function removeRedundantAttributes(tree) {
    const tags = Object.keys(redundantAttributes);
    const tagMatchRegExp = new RegExp('^(' + tags.join('|') + ')$');
    tree.match({tag: tagMatchRegExp}, node => {
        const tagRedundantAttributes = redundantAttributes[node.tag];
        node.attrs = node.attrs || {};
        for (const redundantAttributeName of Object.keys(tagRedundantAttributes)) {
            let tagRedundantAttributeValue = tagRedundantAttributes[redundantAttributeName];
            let isRemove = false;
            if (typeof tagRedundantAttributeValue === 'function') {
                isRemove = tagRedundantAttributeValue(node);
            } else if (node.attrs[redundantAttributeName] === tagRedundantAttributeValue) {
                isRemove = true;
            }

            if (isRemove) {
                delete node.attrs[redundantAttributeName];
            }
        }

        return node;
    });

    return tree;
}

@@ -694,16 +694,111 @@
   %7D%0A%7D;%0A%0A
+const TAG_MATCH_REGEXP = new RegExp('%5E(' + Object.keys(redundantAttributes).join('%7C') + ')$');%0A
 %0A/** Rem
@@ -888,128 +888,8 @@
 ) %7B%0A
-    const tags = Object.keys(redundantAttributes);%0A    const tagMatchRegExp = new RegExp('%5E(' + tags.join('%7C') + ')$');%0A
     
@@ -909,22 +909,24 @@
 ag: 
-tagMatchRegExp
+TAG_MATCH_REGEXP
 %7D, n

bring constants to the top