NoScript and IFrames

Hey There,

I was thinking about my website menu today. It is a JavaScript menu and I know the majority of users have JavaScript enabled with their browsers. So here are a few questions for discussion.

  1. To take into consideration the very small number of users that have JavaScript disabled, many developers use noscript tags. For a JavaScript menu, it may be nice to have at least the top menus within the noscript tag. However, this may bloat the webpages a bit. Would using an IFrame within the noscript tag improve performance overall? I think for JavaScript enabled users, this may be beneficial as the pages would be less bloated with material they do not need. However, for users who have JavaScript disabled, the IFrame creates an extra resource to look up. What are your thoughts on this?

  2. I know my Zapatec Menu has JavaScript libraries that create the HTML necessary to display the menu. If I look in firebug I can see the HTML that is generated. If I copy and pasted all of the generated code in place of the JavaScript code that generates this code, what would be the effect? I can see the pages getting a lot more bloated, which would lead to more time to download the main document. The CPU time on the users computer would be smaller.

  3. Let’s say a user has a menu that has only a top level. This does not have to be a menu - anything in general that has the same code over and over again. Would it be beneficial to place all of this code in an Iframe that can be cached? If a menu is within an IFrame, I do not think it would work if it has drop down menus. I think the drop down menus would be cut off at the bottom of the IFrame. I do not think a z-index would help in this case.

  4. Is there anyway you can cache part of a page instead of the entire page? I was reading an adobe article on coldfusion 9 and it was saying that coldfusion 9 is able to cache the processing for part of a page:

It would be nice if there was a way you could cache part of the page that gets sent to the user. I suppose this is what IFrames are for or is there another way?

Travis Walters

On second thought, this actually would not work with an IFrame because once you click a link in the IFrame the page updates in the IFrame itself and not the parent.

Using JavaScript would be pointless because the IFrame is in the noscript tag.

When I tried this out I had one of those duhhh moments :slight_smile:

_top or _parent should break the iframe if thats your concern…

I’d avoid using frames, and in my opinion even considering frames as a solution is a convoluted one. For both non-javascript users and those with accessibility problems (like those who don’t use mice) it is customary to make the base nav link (the main text the dropdown menu originates from) link to a page that contains the same links that are contained within the dropdown menu itself. That would be my solution to your problem. Though i personally wouldn’t use a menu that requires javascript. Almost all browsers support hover, which allows dropdown menus to be made purely with css, and only IE6 (of course) requiring any form of javascript due to its limited use of hover.

I completely forgot that the a href tag could use _top or _parent. I guess this shows how much I use frames - I try to avoid them as much as possible :slight_smile:

Thanks Sajal for pointing that out. I may go back and give the iframe another glance sometime soon.

I have considered making a pure CSS based drop down menu in place of the JavaScript menu.

This is something I will probably outsource in the future once my website is actually making a little income.

I can see IE6 being completely phased out in a year or two so I am not really worried about that browser. It is becoming outdated rather quickly.

I suppose removing the JavaScript menu and placing a CSS based menu would make my pages render a bit faster.