Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn HTML Minification Off / Enable Whitespace Removal #148

Merged
merged 15 commits into from
Jun 30, 2020

Conversation

iwootten
Copy link
Contributor

@iwootten iwootten commented Jun 16, 2020

What is the context of this PR?

The results of our performance investigation show that html minification has a significant effect on runner's response time. This PR defaults the minification in runner to false and enables whitespace removal through use of jinja flags.

How to review

Check tests continue to pass. Review performance investigation results here: https://github.com/ONSdigital/eq-survey-runner-benchmark/tree/use-non-minified-html

@pricem14pc pricem14pc added this to the v3.44.0 milestone Jun 16, 2020
@pricem14pc pricem14pc modified the milestones: v3.44.0, v3.45.0 Jun 24, 2020
@iwootten
Copy link
Contributor Author

@@ -288,9 +289,11 @@ def __init__(self, option, index, answer):
# the 'pre-' prefix is added to the attributes here so that html minification
# doesn't mess with the attribute contents (the 'pre-' is removed during minification).
# see https://htmlmin.readthedocs.io/en/latest/quickstart.html
attribute_key = "pre-" if settings.EQ_ENABLE_HTML_MINIFY else ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not be getting the config from current app config like we do elsewhere instead of accessing in directly?

app/setup.py Outdated
Comment on lines 114 to 115
application.jinja_env.trim_blocks = True
application.jinja_env.lstrip_blocks = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider grouping these with the other jinja environment changes from line 191, possibly in a setup_jinja_env method.

Comment on lines +64 to +65
- name: EQ_ENABLE_HTML_MINIFY
value: "False"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR says default minification in runner to False, but this is only done on deployed envs atm. EQ_ENABLE_HTML_MINIFY in settings.py should be changed to "False" as the default. Which would mean this change could also be removed as it doesn't override the default.

Copy link
Contributor Author

@iwootten iwootten Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason it is disabled is to boost performance for census. If we were to disable it by default, we may as well remove minification entirely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent was to get it merged, see the performance impact on the daily test, then decide whether to remove it completely in a separate card.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

@iwootten iwootten merged commit 14062e7 into master Jun 30, 2020
@iwootten iwootten deleted the add-jinja-whitespace-flags branch June 30, 2020 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants