Rails 3.1, assets pipeline and IE 6 & 7 in production mode - some CSS & js are not loaded properly

时间秒杀一切 提交于 2019-12-04 23:58:13

问题


Trying out my Rails 3.1 app in production mode ( Debian 6, Ruby 1.9.2, Passenger). I tried it out using IE 6 & IE 7 and some of the assets are not loaded properly. Everything works fine in dev mode.

Some css & js are not loaded properly, thou all the files are being compiled. Specifally I'm having issues with the drop-down ( jquery superfish menu). Everything works fine in IE8, IE 9, Firefox, Chrome both in production & development. The problem only shows up in IE 6 & 7 in Production.

Tried clearing out cache ( both in browser and on the server). Recompiling assets. Nothing sees to help.

Did anyone run into anything - like that?


回答1:


For anyone having the same problem here is the root of the problem from MS Support (http://support.microsoft.com/kb/262161) :

This problem occurs because the following conditions are true in Internet Explorer: All style tags after the first 31 style tags are not applied. All style rules after the first 4,095 rules are not applied. On pages that uses the @import rule to continously import external style sheets that import other style sheets, style sheets that are more than three levels deep are ignored.

ARRRRRRRRRRRRRRR!!! Killed a couple of days trying to track down a problem with my code, when it was MS's non-compliance to standards again!!! #@)(!@#)

This led me to investigate further, and to my amazement IE6 & IE7 seem to process only the first 2025 lines in a big css file - the rest is ignored. ( at first I thought it was a number of lines limitation, but it turns out that it was 4095 rules, that were on the 2025 lines). Just seems plain stupid. Newer IE and Chrome, Safari, Opera and FF don't seems to have a problem with this. I ended up breaking up my css into application-1.css & application-2.css to keep number of the files in produciton to a minimum, but it still very annoying.




回答2:


Is debug enabled? i.e. are your javascript split when in development mode?

Try disabling it so the asset pipeline merges everything up in the same file and see if it still works in development mode.

I've had a few issues when the assets were merged together and there was a missing semicolon in one of the files. This might be a hassle to find, but might happen. Other better browsers render them ok, but IE just mix things up.




回答3:


There is a great module CssSplitter that folks are using to split css files for ie and it has been adapted to be used from the asset pipeline. https://gist.github.com/2398394



来源:https://stackoverflow.com/questions/8621189/rails-3-1-assets-pipeline-and-ie-6-7-in-production-mode-some-css-js-are-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!