rendersubtree for loading a large amount of images at once? - html

I have a lot of images (40.000) on server and their references inside a db table - name, size, date, description etc.
Tried to load all images at once and only 100 of them to be visible, the rest are hidden by css - display:none and become visible by scrolling down.
Result - page loading takes too long and new images becomes visible very slow.
So I go back to the old method - pagination - loading images in steps, clicking on next-prev buttons.
Now I see a new chrome feature - rendersubtree
Could this thing be a solution to load all 40.000 images at once and make them visible by scrolling fluently?
If yes - pls any code example.
Thanks.

It depends why your page is slow. If you're using display:none to hide a whole bunch of content, rendersubtree is unlikely to help in that case.
There's also an img decode API which might help in your case https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode
But before you jump in there, I would recommend doing some profiling to figure out exactly which part of the process is slow. (img loading / layout / etc)

Related

HTML5 prerender/prefetch not working (I get a progressive curtain-like downloading/transition !)

I'm working on a web project and I want to load my webpages with an even transition. What I get right now is my photos and background downloading in a curtain-like manner. I want it to show up when it is all loaded instantly.
I don't mind if there is a progress bar or something but not the curtain-like manner.
I used the prefetch/prerender html 5 tag but with no success..
visit here :
http://hellenic-jewls.com/
and then try to hover to another webpage to see that my images are downloaded progressively like a curtain :
e.g. http://hellenic-jewls.com/classical/
ofcourse when the webpages are cached it's ok.
HTML5 prerender/prefetch doesn't work that way. You use them to hint to the browser that you think that page will be visited next and should therefore be prerendered. There is no guarantee that this will happen though... it's up to the browser to decide if it wants to prerender the page.
Further, there will only be one page prerendered at any one time.
What you can do is hide your images, then use a script like https://github.com/desandro/imagesloaded to signal when the images are loaded, at which point you can show the images (with a fade-in transition if desired)

Add a background music in website and music should not start from beginning if i goto other page

I want to add a background music to my website, but i want that music to play continuously across all pages.
For e.g: i have music which is approx 10min, i am on Home page for 2 minutes music starts from 1 second, when i goto other page the music should start from 2 minutes 1 second.
i've searched across Google & StackOverflow but unfortunately didn't found any answer as per my requirement. :(
i just wanted to know that is it possible to do??? If yes then what kind of mechanism is used for that???
As far as I know, this is not quite easy to accomplish.
There are two practices you may follow, with the first being the most common (IMHO).
Sites that have a music background that doesn't start all over when you navigate, mostly use Ajax or similar methods to navigate, instead of allowing the page to normally refresh. This is mostly common with flash websites, but it is possible to do with Ajax refreshing just the inner content of your site.
The second way would involve somehow passing on a variable that remembers where the user was, but you cannot avoid the loading gaps, and the whole result would be very uncommon and not really pleasant.
There's a few ways you can do this off the top of my head. The easiest would probably be some JavaScript that would load the content of the next page into the current page:
<div id="content">[Your changing page content goes in here]</div>
A link:
Some Page
Some JS:
function loadNext(page){
//using jquery
// assigning to a var like this lets you do things like abort the call
var jqxhr = $.ajax({type:"get",url:page,dataType:"text"});
jqxhr.success(function(result){ $("#content").html(result); });
}
Another, probably simpler way is to load your page content into an iframe and then just have them navigate within that, that'd be a lot safer too as it won't break if people have JS disabled.
<iframe src="homepage.html"></iframe> //You'll need to size this to whatever the content needs obviously, like 'style="width:100%;height:100%"'
Both of these solutions require that your content be able to be separately loaded from the wrapper of the page, so that things like headers and footers don't duplicate infinitely as you navigate around.

results are appended into iframe every invocation

I have an iframe that displays thumbnail images from Flickr in my web application. The problem, I see is when I reload the page, sometimes, I see the same set of images being appended to the earlier set of images. So I get two sets of every image and on a subsequent reload, I get 3 sets of images.
The images are part of a form. So I see multiple submit and cancel buttons as well. Any suggestions on what might be causing this and how I can avoid this from happening?
Pardon my ignorance. I was not resetting my server side variable after the fetch and hence I was seeing the above weirdness. Firebug helped me debug this.

Show html images only when the item is being displayed

I saw this on Hulu.com once, but can't get it to behave that way.
The problem is that I have a "marquee" that slides when you click the next button. There are 2 images per section, a total of about 40 sections.
The issue is that the browser loads all 40 * 2 images and it is consuming bandwidth like crazy.
Is there a way to, saw load the images when the "slide" is shown?
Load them in ajax. Look up jquery for that, it's the simplest way.
It also look like you're doing a carousel. Maybe you could use one of the many existing solutions that already handle assynchronous loading of data.

Seamless FRAME/IFRAMEs (with reasonable scrollbars)?

Summary:
I'd like to display a shopping cart from another domain underneath my fixed content in my page - and have the scrollbars come out properly.
Details:
I need to display a shopping cart from a vendor within a page on "my" site with "my" header on top. (Eventually the shopping will all be in a subdomain but not now, sigh.) The header is a fixed height. The shopping cart pages vary in height as you navigate within that frame.
I've tried frames and iframes and had cross-browser issues with the iframes. I'm only testing four configurations, Windows/IE, Windows/Firefox, Mac/Safari and Mac/Firefox.
Right now I am using a frameset with two frames, one containing my fixed-height header page, the other containing the external page. This does work - the one issue is that when a scrollbar appears it (of course) only appears on the bottom frame.
This will do and the client isn't very sophisticated but it bugs me.
If I use IFRAMES, I find I need to sprinkle height: 100% and overflow-y: auto in various places - and yet I still cannot avoid either one of two unacceptable issues that appear in at least one of the browser/OS combinations...
The combined content is larger than the window, but no scrollbar appears.
An inner scrollbar and an outer scrollbar both appear.
Any hints appreciated!
EDIT:
Thanks for the work - but I don't think I conveyed the issue correctly.
I'm not using frames for layout - I wish simply to make a page framing something on another site (that hosts the shopping cart and whose URL should not be exposed).
Frames "work" - BUT having an interior scrollbar on the second frame and no scrollbar on the whole page is definitely wrong behavior. My client won't know this but it'll look amateurish to people seeing the page.
I don't see quite how a server-side include or CSS would do it and I know both fairly well. If I used the server side include, how would links internal to the shopping cart work? I'd leave my site, correct?
Summary: A shopping cart hosted on another site, embedded on my content page.
Don't use frames, if the user does command + click then the product will open in new window and your frame will disappear.
One feasible solution I see here is with Javascript:
Load the page via $.ajax
redirect all clicks so that it loads in ajax window by
$('iframe a').on('click',function(){
// load the product via AJAX
});
make sure height of Div is not fixed so that it expands automatically and scrollbars are there only on window.
This is best way I could think of keeping the integration seamless while hiding the url