[Resolved] Where to put a code?

Home Forums Support [Resolved] Where to put a code?

Home Forums Support Where to put a code?

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1745629
    Annalena

    Hi! When running my site on googles page speed insight I got a terribly low score, 44 on mobile and 85 on computer, I got the suggestion to put the following code into my html, but where on my site do I find the html? I tried to paste it in simple css but that didn’t work.

    <head>

    <link rel=”preload” href=”styles.css” as=”style”>
    <link rel=”preload” href=”ui.js” as=”script”>

    </head>

    Kind regard
    Annalena Jansson

    #1746252
    David
    Staff
    Customer Support

    Hi there,

    if you want to add those links to the <head> then you would use a Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    Add just the <link> code to the Hook text area.
    Set the Hook to: wp_head
    Then set the Display Rules Location to: Entire Site

    In your code the href=”” will probably need to contain the full URL for the styles and JS files you want to preload.

    #1749809
    Annalena

    Hi David!

    Thanks for your reply. I think I might be able to do it with help of the instruction video, but I don’t know what this means: In your code the href=”” will probably need to contain the full URL for the styles and JS files you want to preload.

    Can you please explain that?

    There are a lot of images on my site, do I need the full URL of each and every one of them to be placed somewhere?

    Thanks!

    #1750161
    Elvin
    Staff
    Customer Support

    Hi there,

    Preloading is specific. This is done specifically on an asset of a specific plugin or theme asset so it loads early as some are required to load earlier than others.

    There are a lot of images on my site, do I need the full URL of each and every one of them to be placed somewhere?

    It’s not exactly good practice to preload ALL images on your site. This is generally done for above the fold images to address CLS and LCP.

    Can you specify what image/s do you want to preload?

    #1751214
    Annalena

    Hi Elvin! The thing is I have no idea what we are talking about, my site loads to slow and when I check what I can do about it, one suggestion was to use: <link rel=preload>, and I don’t know what that is or what to do with it. I have made my site myself by watching youtube, so I don’t know anything about coding. Once upon a time my site loaded in milliseconds and now it takes about five seconds.

    Thanks!

    #1751770
    Elvin
    Staff
    Customer Support

    There’s quite a lot to improve on actually.

    As for preloading things. Performance testing site reports suggest preloading these 2:
    https://share.getcloudapp.com/yAuDJGyz

    But you can actually skip preloading generatepress.woff2 by going to Appearance > Customize > General and set the icon type to “SVG”.

    As for the WPMenuCart.woff2, the theme doesn’t control that.

    But this can simply be done by the caching/optimization plugin you’re using or by doing it manually by hooking something like this on your wp_head by using a Hook element. https://docs.generatepress.com/article/hooks-element-overview/

    <link rel="preload" href="wp-content/plugins/woocommerce-menu-bar-cart/font/WPMenuCart.woff2" as="font" type="font/woff2" crossorigin="anonymous">

    Note: you may have to change the href= value to the URL of your site.

    But I believe this is crucial to address as well.
    https://share.getcloudapp.com/geubEjRp

    This flag is issued when the performance testing site deems your site’s hosting too slow. This is generally addressed by changing to a better performing host/server.

    #1752533
    Annalena

    Hi Elvin! What did you mean by this: But I believe this is crucial to address as well.
    https://share.getcloudapp.com/geubEjRp

    I have put the code you gave me in the element area and I told it to be wp_head, and the priority as it was. Is that correct? Will this increase the loading time to my site? I also changed to SVG.

    Thanks!

    #1752609
    Annalena

    Hello again! Testing my site now after doing the recommended adjustments and it’s even slower! HELP!

    #1752767
    David
    Staff
    Customer Support

    Hi there,

    this:
    https://share.getcloudapp.com/geubEjRp

    That is saying your Hosting Server is taking over 3 seconds to respond when a user tries visiting your site.
    You should speak to your hosting company about this problem. Its a major issue and should be fixed before any other improvements are made to your sites performance.

    #1752859
    Annalena

    Thanks David!

    Did I do it the right way with the code you gave me? I have put the code you gave me in the element area and I told it to be wp_head, and the priority as it was. Is that correct? Will this increase the loading time to my site? I also changed to SVG.

    Kind regards!

    #1752935
    David
    Staff
    Customer Support

    Yep – you did it the correct way 🙂

    Things to note:

    Fonts are loaded asynchronously – so the Browser will happily display the page before the font is loaded.
    The Preload simply tells the browser it must Load it first – so the side effect is that the browser has to download the font before it can display the page – so you notice a little more time taken to initially load the page.

    Thats why the other Initial Server Response time is the main factor for improvement.
    A lot of issues raised on page speed all come down to how fast the server and network connection is. If its fast then you won’t see a lot of issues reported – if its slow then all sorts of problems get raised.

    #1753801
    Annalena

    Thanks David! I have contacted my web host and they told me to increase the memory in FTP, I haven’t done that yet, but if that doesn’t help then I guess I have to switch web host.

    Thank you for now!

    #1754763
    David
    Staff
    Customer Support

    Glad we could be of help.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.