• Skip to main content
  • Skip to primary sidebar
BMA

BeMyAficionado

Inspire Affection

How to Host Google Custom Search on your Web Server

April 15, 2017 by varunshrivastava 4 Comments

Hey guys! You have landed on this page because you want to speed up your website by hosting Custom Google Search libraries and dependencies on your web server and could not find an easy source to accomplish it. Well, in this article I will tell you how you can host Google Custom Search (GCE) on your web server so that it does not add unnecessary load time on the server and also the fact that it is render blocking.

I spent quite some time dissecting google custom search form and how does it work. Google search form that you see on my website just below the navbar, it make use of the the shiny.css file which is offered by google on it’s server. Because of this css file, I was getting a warning in Google Pagespeed Insight tool. This file is not minified and is causing extra load time while rendering the webpage. Can you believe it, google offer unminified version of their css when you generate GCS from google’s console. If you are using GCS on your website make sure you this file is minified and does not block the page render.

Google Custom Search Form

Apart from this, google uses javascript to load entire form. This javascript was again hosted on their servers so there was nothing much I can do for that unless I find out a way to host these dependencies on my server. I started experimenting with the google form and in less than 40 minutes I was able to find the bare minimum requirements for GCS. I only kept the part of the form that was required and rejected everything else. Find the code for GCS below,

<form role="form" class="form-inline" action=URL_OF_YOUR_SEARCH_PAGE id="cse-search-box" style="margin-top: 2em;" _lpchecked="1">



?????<input type="hidden" name="cx" value="YOUR_PARTNER_PUB_ID">

?????<input type="hidden" name="cof" value="FORID:10">

?????<input type="hidden" name="ie" value="UTF-8"> ??

?????<input type="text" style="width: 100%;" class="form-control" name="q" placeholder="Type anything and hit enter...">



???<button type="submit" class="btn btn-green" name="sa">search</button>



</form>

 

Above code is just the bare minimum that you need in order to create a Google Custom Search input box. Now, there is no need of of any external css. You can style this form in whatever ways you want. For ex – Have a look at the above code in action below.

Type anything and hit enter

 

The above search input box is fully functional and does not depend on any other external source. You can try to search from above form and see the results in the results page. Let’s create a search page to show the results of the search query submitted from the above input box.?

CONTINUE READING >>>

Related

Pages: Page 1 Page 2

Filed Under: Programming Tagged With: better pagespeed, cse, embed form, google custom search, search, search engines

Primary Sidebar

Subscribe to Blog via Email

Do you enjoy the content? Feel free to leave your email with me to receive new content straight to your inbox. I'm an engineer, you can trust me :)

Join 874 other subscribers

Latest Podcasts

Recent Posts

  • Is The Cosmos a Vast Computation?
  • Building Semantic Search for E-commerce Using Product Embeddings and OpenSearch
  • Leader Election with ZooKeeper: Simplifying Distributed Systems Management
  • AWS Serverless Event Driven Data Ingestion from Multiple and Diverse Sources
  • A Step-by-Step Guide to Deploy a Static Website with CloudFront and S3 Using CDK Behind A Custom Domain

Recent Comments

  • Varun Shrivastava on Deploy Lambda Function and API Gateway With Terraform
  • Vaibhav Shrivastava on Deploy Lambda Function and API Gateway With Terraform
  • Varun Shrivastava on Should Girls Wear Short Clothes?
  • D on Should Girls Wear Short Clothes?
  • disqus_X5PikVsRAg on Basic Calculator Leetcode Problem Using Object-Oriented Programming In Java

Categories

  • Blogging
  • Cooking
  • Fashion
  • Finance & Money
  • Programming
  • Reviews
  • Software Quality Assurance
  • Technology
  • Travelling
  • Tutorials
  • Web Hosting
  • Wordpress N SEO

Archives

  • November 2024
  • September 2024
  • July 2024
  • April 2024
  • February 2024
  • November 2023
  • June 2023
  • May 2023
  • April 2023
  • August 2022
  • May 2022
  • April 2022
  • February 2022
  • January 2022
  • November 2021
  • September 2021
  • August 2021
  • June 2021
  • May 2021
  • April 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • February 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • January 2019
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016

Tags

Affordable Hosting (4) algorithms (4) amazon (3) aoc-2020 (7) believe in yourself (4) best (4) database (4) earn money blogging (5) education (4) elementary sorting algorithms (4) experience (3) fashion (4) finance (6) Financial Freedom (7) food (7) friends (3) goals (5) google (5) india (10) indian cuisine (5) indian education system (4) java (16) life (16) life changing (4) love (4) make money (3) microservices (9) motivation (4) oops (4) podcast (6) poor education system (4) principles of microservices (5) problem-solving (7) programmer (5) programming (28) python (5) reality (3) seo (6) spring (3) success (10) success factor (4) technology (4) top 5 (7) typescript (3) wordpress (7)

Copyright © 2025 · Be My Aficionado · WordPress · Log in

Go to mobile version