Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Fix Bug 1445889, preload title and body fonts for improved performance #4709

Merged
merged 1 commit into from Mar 28, 2018
Merged

Fix Bug 1445889, preload title and body fonts for improved performance #4709

merged 1 commit into from Mar 28, 2018

Conversation

schalkneethling
Copy link

No description provided.

Copy link
Contributor

@jwhitlock jwhitlock left a comment

Choose a reason for hiding this comment

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

Thanks @schalkneethling, this appears to work (although it is hard to say what would happen if it didn't). I have a couple of nits to address or ignore before you merge.

It's strange to me to ship a tag that FF doesn't recognize, but it looks like we did it for the interactive examples stuff, so it must be mostly working. We should find a way to preload those only on pages that include interactive examples...

jinja2/base.html Outdated
@@ -17,6 +17,10 @@
"noindex, nofollow"
{%- endif -%}
>

<!-- because this is non-blocking, preload as early as possible -->
Copy link
Contributor

Choose a reason for hiding this comment

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

This HTML comment seems more appropriate in preload.html, since it goes with the markup there. If you just want a comment for developers, I'd suggest a {# jinja comment #}.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense.

jinja2/base.html Outdated
@@ -17,6 +17,10 @@
"noindex, nofollow"
{%- endif -%}
>

<!-- because this is non-blocking, preload as early as possible -->
{% include "includes/preload.html" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this included as a separate file rather than inline?

Copy link
Author

Choose a reason for hiding this comment

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

I am a bit of a stickler for this kinda thing. I get a little startled ;) when I open an HTML file and it is this huge wall of code. This is especially true for head sections.

This allows me to have this isolated, it does not add any performance issue, and is simple to update in future.

With all of that said, I am not resistant to change so, if you would prefer I inline this, I am more than happy to do so.

@schalkneethling
Copy link
Author

It's strange to me to ship a tag that FF doesn't recognize, but it looks like we did it for the interactive examples stuff, so it must be mostly working.

In this case browsers other than chrome will just ignore those. We have a large audience of Chrome users and so, it makes sense to roll this out as a progressive enhancement.

We should find a way to preload those only on pages that include interactive examples...

I noticed that these are added on pages where it is not required, as it is just a hint to the browser and not a preload of a bunch of content it is "ok". But I agree, I would want to fix this as soon as possible.

Thanks for the review @jwhitlock

@codecov-io
Copy link

Codecov Report

Merging #4709 into master will decrease coverage by 0.47%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4709      +/-   ##
==========================================
- Coverage   95.94%   95.47%   -0.48%     
==========================================
  Files         270      262       -8     
  Lines       25352    23844    -1508     
  Branches     1743     1715      -28     
==========================================
- Hits        24325    22766    -1559     
- Misses        817      870      +53     
+ Partials      210      208       -2
Impacted Files Coverage Δ
kuma/wiki/views/delete.py 62.29% <0%> (-34.68%) ⬇️
kuma/feeder/models.py 71.42% <0%> (-28.58%) ⬇️
kuma/attachments/views.py 84.74% <0%> (-6%) ⬇️
kuma/wiki/admin.py 76.23% <0%> (-3.22%) ⬇️
kuma/wiki/views/document.py 90.31% <0%> (-1.16%) ⬇️
kuma/wiki/models.py 91.82% <0%> (-0.72%) ⬇️
kuma/wiki/views/revision.py 92.55% <0%> (-0.38%) ⬇️
kuma/wiki/views/legacy.py 87.5% <0%> (-0.31%) ⬇️
kuma/wiki/tests/test_views_document.py 99.29% <0%> (-0.26%) ⬇️
kuma/core/views.py 95.45% <0%> (-0.2%) ⬇️
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34f6a6d...469ef7f. Read the comment docs.

@jwhitlock jwhitlock merged commit 7fbb4dd into mdn:master Mar 28, 2018
@@ -0,0 +1,5 @@
{# because this is non-blocking, preload as early as possible #}
<link rel="preload" href="{{ static('fonts/locales/ZillaSlab-Bold.woff') }}" as="font" type="font/woff" crossorigin />
Copy link

Choose a reason for hiding this comment

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

Why preloading the .woff file in addition to the .woff2 file ? Modern browsers will need only the .woff2 file as they support this format (and older browsers won't preload anything anyway)

Copy link
Contributor

Choose a reason for hiding this comment

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

See #4728

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants