-3

I am working on adding a feature to a forum where I look for keywords in posts and add links to these keywords. For example, say a user's post includes the phrase "HP Printers". This phrase would be picked up by my regex and then I would link the word to the HP company page.

I have this implemented in php so it searches (about 1000+ expressions) and adds the links before the response is sent. This slows down page load times obviously. I would like to load pages as fast as possible. What would the drawbacks be to implementing this code client side in Javascript, that way I could allow the page to load even if the links have not all been put into place yet? Are there any unforeseen consequences that I may run into from implementing this in Javascript instead?

Thanks in advance!

  • 2
    Websites with links in keywords... Worst surfing experience ever. I avoid such sites like the plague. – Robert Harvey Aug 7 '17 at 1:14
  • I'd think that your 1000+ expressions could be a lot faster if you'd combine them into a single regex. – amon Aug 7 '17 at 8:48
1

The most obvious consequences are that the page load time is likely to go up and that people get the opportunity to disable your keyword linking.

The load time is likely to go up because you have a lot more data to transfer to the client side (every page will now have to include your entire database of keywords and corresponding links) and it is also likely that the (javascript implementation on) the client machine is slower than the (PHP implementation on) your server, or at the very least you can't influence how fast the client machine is while you do have influence on the processing power of your server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.