Javascript script adaptation 'show more'

Asked

Viewed 330 times

1

I’m using a script that was posted here in stackoverflow, which is to limit the display of posts accompanied by a 'show more' link, to load another amount of posts.
Follows the LINK
Note: If necessary, I put the full code here in the question.

It starts loading three posts, and every click loads
I wish you’d take away my doubts:
I am not limiting the amount of record that will appear in the ugly SELECT with PHP, so if there are 200 records, all will be displayed, but thanks to the show more script, only the first three will be displayed on the page. My question is: when the user loads the page, this load will be done with the total of posts in the database, or the total of javascript?

Another question: If I start displaying only 3 posts with javascript, and not limiting SELECT with php, even if there are 100 records, will influence SEO?

  • I think the link posting fails, edit the question with the link.

  • Thanks for the warning. I updated!

1 answer

2

For large amounts of content this will be a serious problem, the advisable and make pagination of your posts, that is, instead of loading the existing "200 posts" in your database and letting all this information be controlled by javascript to show 3 in 3, it would be more advisable to carry out a specific query that uses skips, in case to perform a more optimized query in order to take only the necessary data, an example of this would be:

SELECT FIRST 20 SKIP x * FROM TableName

In this case Voce selects only the first 20 records and works with them, the request to the server is lower the first time and with this Voce ensures that only what the user wants to access will be downloaded.

Answering to your doubts:

When the user loads the page, this load will be done with the total of posts in the database, or the total of javascript?

As Voce does not limit the amount of posts in your select it will receive the total database, javascript will only show it little by little.

If I start displaying only 3 posts with javascript, and not limiting SELECT with php, even if there are 100 records, it will influence SEO?

This is a great question :)

Imagine the following situation, Voce enters the The New York Times, his favorite newspaper, to see only the latest news, why Voce accompanies every day. Imagine if they used the method that Voce described, in the case of the new york times, they have at least 34,000 publications, the load of this information at once would either crash your browser or if you were using data would wipe out your rsrs package. but the focus is not that, I can’t tell you with certainty but the more a page and slow less users are adept to use them.

Recommended references to implement a page:

Asynchronous paging with jQuery, Ajax and Mysql

Automatic paging with PHP and jQuery

Pagination with jQuery and PHP - Youtube

jQuery/Javascript simple paging - Stackoverflow

  • Thanks for the very valuable reply! So how would these skips look? Because I am not limiting the query, and currently has 18 records, but in a week will exceed 50, and a user accessing through data will be without, because it loads videos up.. I need to limit, and only then do the action with javascript, but I have a doubt: Let’s imagine that I have 20 records and that my javascript shows 2 by 2. With a Skip in the query, I could make it follow the script to load more?

  • Highlander, can complement the answer?

  • Yes, I’ll add some references to help you, but I’ll give you an advance, search by paging, in your case using php+ajax

  • I totally understand. I would just like a clearer answer, because, I don’t know if I’m correct, but it seems to me that with "SELECT FIRST 20 SKIP x * FROM Tablename", the first 20 will be selected, and my javascript displays 5 in 5. Okay, so far so good, but what about when you get to 20? the server will search for 20 more? Because of the current way my select search.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.