Javascript – Client-Side V.S. Server-Side Searching

javascriptPHPsearch-engineweb-applicationsweb-development

I am currently helping to design a web site and application in HTML. We would like the user to be able to search the site/app for desired content via a search bar. We would also like to include an advanced search ability to allow for different search options and more concentrated searches.

We are having trouble deciding whether to program the search function on the Client-Side (with JavaScript) or on the Server-Side (with PHP). What are the pros and cons of both and what would you recommend?

Best Answer

As others have commented on your question, you need server-side functionality to provide effective and efficient search in a website; otherwise you would need to make all searchable content available to the client-side search engine; unless the volume of searchable content was very small, this would be troublesome.

Once you have the server-side functionality, yes, you can add AJAX to make searching niftier- esp. autocomplete functionality, quick filtering, etc., although that's also going to rely on the server-side functionality.

My personal point of view; if you do have the time to do AJAX and it adds speed, do so. But it is time-consuming and perhaps your time would be better spent some place else.

Related Topic