Question

I'm designing a single page website. All the sections to the site pop up modally in DIV elements, so it never leaves the actual browser page. Initially I have all the sections hidden with css using "display:none", and the navigation reveals and hides them accordingly.

Now I've come to putting together the portfolio section, I'm starting to wonder whether it would be best to use AJAX for each portfolio item, as they include larger images. Is there any rough guide to what's a sensible limit for preloading? If all the items were preloaded, the HTML file would look quite monstrous.

I realise this is a bit of a general question and it feels like preloading everything is a bad idea but I don't want to go on a hunch. I'm not quite sure what sort of resources are taken up with the user's computer when elements are set to "display:none" (e.g. Is it a RAM issue?).

Cheers! :)

Was it helpful?

Solution

As @Digbyswift mentioned, having one large HTML file with lots of elements increases the page size, which has an impact the overall load time.

For older browsers, the number of elements on the page had a _much_more noticeable effect, but you would have to get in to the 10s of thousands of elements range to start hitting the ceiling.

For modern browsers, you don't have as low of an element-count ceiling, so you should be fine there, but again, if you are doing a lot of javascript interaction with the elements, it will slow down less powerful clients, such as mobile devices.

The biggest trade off you are dealing with, in my opinion, is that by having one much larger page instead of a bunch of individual calls, you are effectively trading size of a single server response with the number of smaller responses needed. Depending on your specific case, it may be a beneficial overall trade, or it may not.

I would say that you need to test the differences it makes and base your decision on that. One thing that will affect this are using compression on the responses (aka. GZip or Deflate).

Also, for the "portfolio", you mentioned that there are lots of large images. Personally, I would probably not have the actual <img /> tags in the HTML for that section to prevent the browser from loading all of it initially and instead load the images in as needed by writing the elements in with javascript as those images need to be displayed. There are a number of techniques to do this, any you can add in more smarts around when the images get loaded, but reducing those large server calls will speed up the page a great deal. Likely even to the point that having one massive HTML page won't be a performance hit and will likely make it faster.

OTHER TIPS

The issue of hard-coding all the elements into the HTML is predominantly how large the file becomes and therefore how long it would take for a user to download that HTML page. It depends who your audience is and how you are expecting them to access the page. For example, a large HTML page isn't appropriate for mobile devices.

However, you would need to trade off whether the AJAX script required amounts to more file size than the actual hard-coded HTML.

First, there are a huge memory on modern browser (such as Firefox, Chrome, IE,...). Users can set it more and more easily...

In mobile browsers, they limited about 10MB. You can read more about limit memory here: http://www.yuiblog.com/blog/2010/06/28/mobile-browser-cache-limits/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top