Does a webpage load images slower if there are multiple sources? - javascript

Scenario 1: I post pictures on my Facebook profile and create a webpage that has image SRCs linking to the Facebook profile
Scenario 2: I link my SRCs to images from Google searches. This means multiple sources for my images.
Is scenario 1 faster than scenario 2 since it's pulling from one page, or are they the same because each image SRC is a request that takes time to process depending on the source?

Related

How to load multiple iframes with same src on one page

I am creating a WordPress based website and I have a web page where there are multiple iframes with the same src.When I load this page all iframes are showing the same result, but every iframe should have different iframe content with the values sent using session(used for sending data from a PHP file to another PHP file) from where iframe is defined to the iframe src.The web page basically contains users of the website giving different reviews.The iframe in the web page is used for displaying star rating given in each user review.So, each iframe is displayed with values(userid,etc.) to display user's star rating and other user related data.
An image of a webpage:
An image of the iframe:
Use Ajax instead if it's on the same server.

How to preload and cache URLs/links using JavaScript?

I have a signup page that has links to 3 different pages. I want to preload all 3 of those destination pages while the user is still on the signup page. This way, the user does click it, it will load immediately.
Is it possible to do this using AJAX or an iframe and have the contents of the URL cached to by the browser?
Now chrome supports dns prefetching. But it is pretty new and not all browsers supporting it.
You can load all the resources(scripts, styles, images) in the upcoming pages in your signup page dynamically. In this way browsers will cache the resources. And, if you are using partial templates, you can preload that also.
This can be achieved with ajax.
On page load start loading the three pages, as soon as you receive each html file place them in three different hidden divs, when the user clicks a link hide the correct div. Remember to check what happens if the user clicks a link before you get your html back

loading web page images after the page is loaded

In my website (that is for baby names), 40 names are shown in each pages, and each name can have a picture that are uploaded by users.
now that number of names with pictures has increased my pages are very slow. by the way images are loaded from CDN and my concern is only for client side page load time.
first I decided to to put a 1x1 empty gif image as src and load actual images after the page load completes
<img src="x.gif" data-src="the-real-image-src.jpg" class="delayed-load" />
$(window).load(function () {
$('.delayed-load').each(function(){
$(this).attr('src',$(this).data('src'));
});
});
but later I thought that as Images are being indexed by search engines it will have a bad influence on it. so I decided not to change real srcs and just cancel loading images before they start and retry loadin after page loaded. as I researched canceling image load doesn't prevent browser download te image so this one failed too.
I can add Images after page load too but it has the same problem as the first choice (that page source doesn't contain real image links.
what would you suggest to keep it both search engine friendly and also load images after page completion?
Add a width="<value>" and height="<value>" to your img tags (in pixels). This will allow the page text content to render before the images are fully loaded. No javascript required.
<img src="x.gif" width="42" height="60" data-src="the-real-image-src.jpg" />
Note that I assume either you have the same width and height for each image, or you've stored the metric somewhere you can access it on this load.

HTML5 Canvas Example Screenshots

I have come across html2canvas thanks to a previous question of mine. What I am confused about is how could I implement it to do the following:
Create a live thumbnail of a live website.
When the live thumbnail is clicked it loads a bigger image of the website.
What would be the best way to feed the uri's into the script?
All images will have specific hxw set in the image tag or the css for the specific class.
If the website you are trying to create a thumbnail for is different from the actual page the user is on, you'll need to first download the HTML of the page to your server (same origin), after which you can wrap it inside an iframe and create a screenshot of that.
The screenshot generated will be 1:1 size with the actual site, so to create a thumbnail you'd have to resize the screenshot.
The script doesn't accept HTML, url's or anything else except for DOM elements as an input for rendering a page. As such, the only way you can generate a screenshot using the script is to have it either load on the page where you want the screenshot to be generated or load the page within an iframe (under same origin, so you'll need to download the source through a proxy if you use cross-origin).

How to change Image Loading Order (for Lightbox)

I've got a page with a lot of images (thumbnails). You should be able to expand the images via Lightbox. I need to encourage the browser to load the image in the Lightbox before any other image (thumbnail).
I remember some articles (I can't find anymore) on how to influence the loading mechanism of the browser (use a different subdomain to allow another thread), but I'd like to know whether there might be other options (i.e. without additional subdomains).
To clarify the issue:
Example (how I'd like it to behave)
I visit the page
I click on the 3rd picture thumbnail
The 3rd picture is shown (while the remaining thumbnails are loading)
Example (how it behaves right now)
I visit the page
I click on the 3rd picture thumbnail
A spinning wheel is shown until all thumbnails are loaded
The 3rd picture is shown
Are there any tutorials/papers/views on this issue?
Just did it with using jQuery $('<img>').attr('src', ...) in my custom queue-manager which limits the browser to load images 1-by-1 thus having the capacity to load additional images that might be showing up on the page (like the one in the lightbox).

Categories