On a Ruby on Rails development environment, a page will be shown after 30 seconds on Firefox, but takes 90 seconds on IE 8 (with IE 7 Compatibility Mode).
Further investigation shows that it should be Javascript that slowed down the page, because if Javascript is turned off, then the page content will also show in 30 seconds.
Because there are probably 7 or 8 jQuery plugins, Facebook scripts, and Google Analytics script, it would take quite some time to move all the Javascript code to the end of the HTML file, (which should speed up the page content view so that content is shown after 30 seconds, just like Firefox), is there a way to force IE to show page content before finish executing all the Javascript code?
I think IE might be waiting for all Javascript code to finish first, because what if there are document.write()
statements, which should be within the HTML... Firefox or Chrome doesn't wait for that but display the content right away.
(on the production server, the page will be displayed on Firefox after 5 to 7 seconds, because a lot of the "partials" (HTML sub-components) are cached. IE 8 takes a lot longer too, about 40 seconds or so.)
P.S. A strong reason why the Javascript is embedded throughout the HTML may be that, say if there is an "Image Carousel", then the HTML code is in a "partial", which is an HTML file generated by an HAML file, and all the HTML as well as the Javascript code are in this file, for better encapsulation, instead of having HTML in one file, and the Javascript in another file, but I wonder what if all these Javascript code blocks only use jQuery's $(document).ready(function() { ... })
, then will these code block slow down the page display on IE?