You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found several issues here caused by incorrectly removed HTML attributes, and I've recently opened a new one. I'd like to share my workaround, hoping it might be useful to someone, until a better solution is available.
The basic idea is to replace incorrectly removed strings with a unique string sequence and restore them after minification. My example is in Python, but it can be easily adapted to other programming languages.
defunique_id():
# uuid.uuid1() is a function from Python standard# library that generates unique idsreturnstr(uuid.uuid1())
strings_to_preserve= [
['target="_self"', unique_id()],
['type="text"', unique_id()]
]
# Replace strings with unique ids that will be preservedforstring, idinstrings_to_preserve:
html=html.replace(string, id)
minified=minify_html.minify(html)
# Replace preserved ids with original stringsforstring, idinstrings_to_preserve:
minified=minified.replace(id, string)
I haven't tested this approach beyond attributes, but it should likely work for other cases as well.
The text was updated successfully, but these errors were encountered:
Hi!
I've found several issues here caused by incorrectly removed HTML attributes, and I've recently opened a new one. I'd like to share my workaround, hoping it might be useful to someone, until a better solution is available.
The basic idea is to replace incorrectly removed strings with a unique string sequence and restore them after minification. My example is in Python, but it can be easily adapted to other programming languages.
I haven't tested this approach beyond attributes, but it should likely work for other cases as well.
The text was updated successfully, but these errors were encountered: