'show more' script adaptation with javascript

1

I'm using a script that was posted here in stackoverflow, which is to limit the display of the posts accompanied by a 'show more' link, so that it loads another amount of posts. Follow the LINK
Note: If needed, I put the complete code here in the question.

It starts loading three posts, and each click loads I would like you to ask me questions:
I'm not limiting the amount of registration that will appear in the ugly SELECT with PHP, so if there are 200 records, all will be displayed, but thanks to the script to show more, only the top three will be displayed on the page. My question is: when the user loads the page, will this load be done with the total posts of the bank, or the total of the 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 it influence SEO?

    
asked by anonymous 27.12.2015 / 02:25

1 answer

2

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

SELECT FIRST 20 SKIP x * FROM TableName

In this case you select only the first 20 records and work with them, the request to the server and smaller first time and with this you ensure that only what the user wants to access will be downloaded.

Answering your questions:

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

As you do not limit the number of posts in your select it will receive the total of the 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, will it influence SEO?

This is a great question :)

Imagine the following situation, you enter the The New York Times , your favorite newspaper, to see just the latest news, why You follow it every day. imagine if they used the method you described, in the case of new york times, they have at least 34,000 publications, loading this information in one go or stopping your browser or if you were using data would end up with your rsrs package. but the focus is not this, I can not say for sure but the more a page is slow and the less users are adept at using them.

Recommended references for implementing a page:

Asynchronous pagination with jQuery, Ajax and MySQL

Automatic pagination with PHP and jQuery

#

27.12.2015 / 05:23