27
dayo
7y

I just found this bit of code in our product :P

setInterval(function () {
$("body").find("div, td").replaceText("oldProductName", "newProductName" );
}, 50);

Comments
  • 0
    Don't really see the problem here besides client performance.
  • 0
    @olback why replacing it every 50ms when you can do it once at pageload?
  • 0
    @resdac maybe some data is loaded async?
  • 0
    @apisarenco then make it a function and implement it in the ajax. Success/done :)
  • 0
    @resdac What if there is some sort of 3rd party framework involved, and AJAX requests aren't specified explicitly?
    I had this. All I could do is attach to events, wait a bit for the data to be added to the DOM, and then parse the DOM and do the replacements. Well at least like that. Previous guy did code it as an interval.
  • 0
    @apisarenco you win haha
  • 0
    @resdac Live update without reload? I don't know.
  • 5
    They can't just change the product name once in the DB? 🤔😀
  • 1
    There is only one occurrence of the produce name in our software and that is loaded on page load 😓
  • 0
    but what if the product name is in a h1 or p? Or what if a third party site refers to the old name?

    Better just infect your clients with malware so you can install a network traffic sniffer which replaces all occurrences directly in the packets.
Add Comment