We typically used this to replace our even older method that involved 2 other JavaScript files… yes this replaced 2 files!! We simply add it to our normal global scripts file (scripts.js), update the ID/Class for the sites search field and call it a day!

For the most part this has worked great… until today! I am currently working on a site that we are making responsive and in order to do that efficiently I am cleaning up as much extra as I can. We want to minimize everything we can to ensure that with this enhancement there are no effects on page load. So I go to add it as I normally would but to be sure I first searched the site for all instances of the ‘clearDefault’ class that the (even older) JavaScript was using. I mainly did this so I knew what to test once I put the new code in place but instead I was in for a pleasant surprise of multiple instances with multiple values to replace! So I had to take a step back and reevaluate our current solution to include other scenarios.

Note: This does require jQuery on the page but for the most part all of our sites already have jQuery so we decided to use it where we could.

Suggestions

I am not saying this is the only or absolute best way to handle this but it is the solution that fit our needs. If anyone has any suggestions on how this could be improved or done in a more efficient way please comment below!