Skip to content

Performance issues with translation #14

@bndn

Description

@bndn

The code in this plugin has some performance issues regarding translation.

First, it’s urgent to modify the function ogf_fonts_array() by moving $weights declaration before the fonts array items iteration. This makes 80 000 useless calls to esc_html__() less, which saves up to 5 sec of page loading.

Next, there is some design problem with this function:

  • it loads translation to generate a list of fonts used for the front end and not only for customization where translations are printed;
  • it loads translation of font weights for each fonts but these weights translations are always the same;
  • it is called up to 9 times by page load and always generate the same array of fonts;
  • it creates an array from a static json file where font variants are always altered the same way.

IMHO, font weights translations should be made one time for the full list of possible weights and only when the strings are printed (e.g. in the customizer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions