23
oztek
6y

So today one of my client told me that my script is freezing their website on IE browsers. I tested and told them that website is being freezed even without my script.
Now they sent me analyzed scenario and they concluded that it freezes 4 out of 10 times without script. But it freezes 12 out if 15 times with script -_-. So there is something really wrong with the script and I need to fix it urgently otherwise they will kick me out. #fuckedupLogic
Funny thing is that same script is loaded in so many other client's website and it doesn't freeze any shit.

Comments
  • 4
    If a script works in one website and not in other, means there is some clash in the jquery library versions..
    Maybe it is using some older version of jquery to execute
  • 1
    @PhpForever I'm not using jquery in my script
  • 1
    IE forces a redraw of all children everytime you use JavaScript to add a class, remove a class or inject style attributes to an element.

    Is your script adding display:none to a butt load of elements? If so, it will freeze the browser until all related elements are redrawn.

    Instead, consider using JavaScript to add or remove a class name of “hidden” and let the CSS handle the hiding and showing. It seems weird, but IE uses a different, more efficient engine to re-render elements that are hidden with the class name method.
  • 0
    @lewdogg not exactly.

    But my script is adding removing dom element on some specific element click. (Not adding/removing class though but the whole dom element).
    Maybe that is the reason of hanging. But it hangs on IE only and onthat customer's page only and not on other page (same script)
  • 1
    @oztek do those elements have style attributes? If they do, just use class names instead.

    I have no idea what you are doing, so it is speculation. This is just the issue I have always had with IE.

    I have begun to even adopt using methods that check to see if a class name is already present. You aren’t using jquery, but the jquery addClass method in IE will continue to keep adding the same class name over and over again, triggering a redraw even though nothing has changed. Instead, I use my own method “addClassIfNotExists” which will check first before adding. For a show/hide script, this will only “hide” an element if it is not already hidden. Other browsers are way more efficient, so no worries.

    In short, IE can go straight to hell.
Add Comment