Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS how to insert preload in my shopify store logo code

Breno Gomes

New Coder
Hello everyone, how are you? I would like to know what should I modify to preload the logo so that I can improve my store LCP speed on page speed. Sorry I don't understand anything about codes

This is the code I found in the store theme at ''header.liquid'', I think it refers to the logo.

Code:
 {%- capture header_logo -%}
          <a href="{{ routes.root_url }}" class="header__logo-link">
            {%- if section.settings.logo != blank -%}
              {%- capture image_size -%}{{ section.settings.logo_max_width }}x{%- endcapture -%}
              <img class="header__logo-image"
                   style="max-width: {{ section.settings.logo_max_width }}px"
                   width="{{ section.settings.logo.width }}"
                   height="{{ section.settings.logo.height }}"
                   src="{{ section.settings.logo | img_url: image_size, scale: 2 }}"
                   alt="{{ section.settings.logo.alt | default: shop.name | escape }}">


This is the code I found in the store theme at ''minimal-header.liquid''

Code:
<h1 class="header__logo">
          <a href="{{ routes.root_url }}" class="header__logo-link">
            {%- if section.settings.logo != blank -%}
              {%- capture image_size -%}{{ section.settings.logo_max_width }}x{%- endcapture -%}
              <img class="header__logo-image"
                   src="{{ section.settings.logo | img_url: image_size }}"
                   srcset="{{ section.settings.logo | img_url: image_size }} 1x, {{ section.settings.logo | img_url: image_size, scale: 2 }} 2x"
                   alt="{{ section.settings.logo.alt | default: shop.name | escape }}">
            {%- else -%}
              <span class="header__logo-text">{{ shop.name }}</span>
            {%- endif -%}
          </a>
        </h1>


Site link: Ponto Descontos Site Oficial - O Ponto da Felicidade com Frete Grátis
 

Attachments

  • logo pagespeed.png
    logo pagespeed.png
    47.4 KB · Views: 3
Okay, diving right into your query. I get it, coding can be a bit of a maze if it ain't your thing. Let's break it down.
You wanna preload the logo, right? You need to add the preload link in your <head>, not where you found your logo code. It's gonna look something like: <link rel="preload" href="{{ section.settings.logo | img_url: image_size }}" as="image">
This bad boy tells the browser to give priority to your logo, so it loads up quick. Helps with that LCP speed you mentioned.
 
Last edited by a moderator:

Buy us a coffee!

Back
Top Bottom