Reputation: 970
I have a page with a few big tables. When loading this page or triggering an event is fast enough with Chrome but when I run this in IE7 the page is slow.
Sometimes if I click a button it takes a few seconds before it is loaded instead of instant action with Chrome or FF.
I Googled a around a bit to find an solution to this problem and I tried the HTML validator. If I save a page in HTML format and insert it in the validator I get 1K+ errors, most of these errors are tags that are not closed.
If I check the ASP code, which is very limited because all the code is written dynamically with objects (I didn't write my own HTML code), all my tags are closed and I don't get a single warning or error in Visual Studio.
In this page I use jQuery and some custom JavaScript (nothing to complex). All my data comes from SQL server, If I ran all the queries at once it's still less then one second, pretty sure these queries are written as best as possible.
Any idea how I can make the website faster in IE? (Unfortunately 90% of the users have IE7)
Upvotes: 1
Views: 1384
Reputation: 6764
I would recommend that you install the plugin yslow on firefox and check what kind of score the plugin gives your site and what recomendations does it give to optimize the site.
Also, you should know that IE 6-8 is extremely slow at compiling javascript and at DOM manipulation. The crudest way of identifying javascript slow downs I know of, is to simply comment out javascript functions from your page, one by one, until the site starts loading fast. Then you work on optimizing whatever function you think loads slowly.
Upvotes: 1
Reputation: 803
Without seeing any code, it's hard to assert why these performance issues arise. One thing I can think of is how jQuery works in IE7
Simply put, when you are using a selector in jQuery (like $(".some-class")
) jQuery will use the native function document.querySelectorAll
, which queries the DOM using CSS selectors (unless you're using jQuery-specific selectors like :animated
). However, IE7 does not have an implementation for the querySelectorAll
method, which causes jQuery to search the DOM in a more iterative way. I'm not entirely sure how this works, but I'm sure one can find out at sizzlejs.org
Now if you have a very large HTML document in IE7, and you are, for instance, attaching events to each row in your table like so: $(".some-class-that-marks-as-clickable").click(...)
, jQuery will have to look for all these rows and apply the handler. If this is the case, it can easily be remedied by using the onclick attribute on each clickable element instead.
Of course, since you have not posted any code I cannot guarantee that this is your problem. I only know I had that exact problem a few years back, which caused IE7 to render the page in ~45 seconds, while Firefox did in less than one second.
Upvotes: 1