This topic has 15 replies, 2 voices, and was last updated 9 years by sharmstr.

  • Author
  • #85681
     mitchcan
    Participant

    This is really a ‘best practices’ type of question. My site loads horribly slow, specifically on mobile. I’m trying to resolve.

    I have WP managed server/server side cache, and we use a CDN.

    Let’s say I have 1,000 posts total on the site. I want to load 20 or so posts on the initial page, and want to have other posts available to see via the page #’s (eg 1-50) on the bottom of the page and/or via search.

    Are ALL (e.g. 1,000) the posts loading with the INITIAL page (even tho I only have 20 that ‘display’) or are they only loading once I go to page2 or page3 etc…?

    Thanks.

     

    #85708
     sharmstr
    Moderator

    Only 20 at a time are loading. Read this my friend: https://codex.wordpress.org/Function_Reference/query_posts

    And before you come back after reading it to ask about Kleo using ‘query_posts’ (LOL), Kleo indeed uses query_posts in the Kleo Posts shortcode. But again, its not pulling back all 1000 posts.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85735
     mitchcan
    Participant

    Thanks! Good info. So I won’t ask about Kleo using query_posts 🙂 but…

    A curiosity question: So I am not specifically using a kleo posts shortcode on the page in question (the default ‘blog’ page) but if I were to place a Kleo shortcode (with the various data/settings options provided for) on any page, it would return posts in the same way, right?

    And then back to the original issue. That page load for the 24 posts in chrome on mobile takes over 30 seconds to display the posts. Besides not using a mobile device 🙂 any other ‘best practices’ or recommendations for Kleo page load performance?

    Thanks as always.

    #85745
     sharmstr
    Moderator

    Yes, it returns it in the same way, but it does it twice

    Additional SQL Queries
    If you use query_posts within a template page, WordPress will have already executed the database query and retrieved the records by the time it gets to your template page (that’s how it knew which template page to serve up!). So when you over-ride the default query with query_posts(), you’re essentially throwing away the default query and its results and re-executing another query against the database.

    This is not necessarily a problem, especially if you’re dealing with a smaller blog-based site. Developers of large sites with big databases and heavy visitor traffic may wish to consider alternatives, such as modifying the default request directly (before it’s called). The request filter can be used to achieve exactly this.

    The ‘parse_query’ and the ‘pre_get_posts’ filters are also available to modify the internal $query object that is used to generate the SQL to query the database.

    Since you already have caching and a cdn, the only other things you can do is make sure the plugins you are using are optimized. Get rid of the ones that arent: https://wpengine.com/blog/plugins-and-fast-wordpress-sites-its-not-the-number-of-plugins-its-the-quality/

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85746
     sharmstr
    Moderator

    More info on Kleo Posts: The kleo post shortcode doesnt have paging so its only ever going to pull back however many posts you specify.

    Also, the standard WP post query will only pull however many posts you have set up in Settings > Reading. When you go to another page, it specifies an “offset” and again only pulls however many posts you have in settings.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85749
     mitchcan
    Participant

    OK, that’s what I thought it meant when I read it. 🙂

    Yes, I have a lot of plugins, but I really only have them if I need the functionality. It’s not like I’m collecting them. 🙂

    And in that other link (thank you for the info), it lists specific things to be wary of in a plugin (and, by extension, I would think a theme):

    Does it load lots of scripts, styles, or other assets?
    Does it add extra database queries to each page?
    Does it perform complex operations?

    So with all this information, it begs to ask… Why must Kleo work this way if it is a known issue for performance?

    #85757
     sharmstr
    Moderator

    I suppose if you dont want a site to load a lot of scripts and styles, you can use the default WP 2015 Theme 🙂

    If you want style, we need to load styles. If you want functionality, we need to load scripts. There’s no way around that man.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85762
     mitchcan
    Participant

    LOL. Nah, gonna use 2010 Theme – I’m all about the State of the Art. 🙂

    OK, so are you saying that to be all the cool stuff Kleo does – THAT’S why it has to do the ‘query_posts’?

    This was what struck me:

    As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like making use of pre_get_posts hook, for this purpose.

    I’m just trying to get a handle on this speed/performance issue. I was looking to buy a couple more licenses for two other sites and I don’t want to go down a road I regret later.

    Thanks @sharmstr

    #85765
     sharmstr
    Moderator

    Back up.

    As I said, query_post is only used the in Kleo shortcode.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85766
     sharmstr
    Moderator

    ….. and has nothing to do with loading of styles and scripts…..

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85771
     mitchcan
    Participant

    OK. So backing up… all the way to my initial question.

    I do NOT use the Kleo shortcode on the page in question. I simply have set that page as my ‘Posts’ page; have 24 posts set in wp > reading; and in Theme Options > Kleo display type as Grid Masonry. No shortcode. I should have explained that better.

    In this set up, does ‘query_posts’ run twice?

    I’m simply trying to look at performance issues. 30 seconds to load posts on a mobile device won’t fly. The header loads, the sidebar loads, but the posts just take for – ev – er. Looking to resolve, that’s all.

    Sorry to have gotten a little off-track. (Though the new found info for situations where I might want to use the Kleo shortcode IS helpful.) Thanks for the redirect. 🙂

    #85775
     sharmstr
    Moderator

    No it does not.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85780
     mitchcan
    Participant

    Good deal, so scratch that as the problem.

    So now I need to figure out what is causing the performance issue on mobile.

    Here’s something interesting. I’ve had an android for several years – and therefore was used to using Chrome. I just recently went back to iphone. Loading this page in *Chrome* (on iphone) is horribly slow – seriously, like 40 seconds. But now testing the load of the page in *Safari*, it’s relatively normal, < 5-6 seconds. Go figure.

    Any thoughts there? Besides not using Chrome (which I’m personally fine with on iphone, just worried about visitors).

    Thanks for your time in the rambling thread. Have a great day!

    #85787
     sharmstr
    Moderator

    I have no idea. I dont have an iPhone. I’m all google/samsung baby. Have you googled (LOL) possible reasons why the speed difference? Have you tested out non-kleo sites between the two browsers to see if its indeed a browser difference issue?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85789
     mitchcan
    Participant

    Honestly, I was so used to using Chrome on my Galaxy, I never even considered it to be a iphone/chrome issue until I was testing it during our thread. It just didn’t occur to me that it would act differently on Safari.

    I wouldn’t have been surprised that Apple would make (purposefully?) something from Google not function right on their device. LOL.

    But I just tested several of our Genesis-theme sites in Chrome on my iphone, and they loaded fine right away. Same with those sites on Safari. So it’s strange, but looks like it might be something to do with the way the Kleo loads/displays the posts on the ‘blog’ page in Chrome. No clue.

    I don’t know either. I need to spend less time on this. I would think that iphone/ipad users would *primarily* use Safari, so it wouldn’t matter much. I’ll need to look at some analytics and do more testing and go from there.

    If nothing else, it’s something to have out there, maybe someone else is experiencing the same thing.

    Moving on for now. 🙂

    #85792
     sharmstr
    Moderator

    Good chatting with you as always 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 16 posts - 1 through 16 (of 16 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?