Load image only when it is viewable? - javascript

I saw some web page which has a large number of images, only the images inside the scrolled viewport is displayed, for the outside images, when I scroll down to it, it will be loaded.
How that can be done?

try this jquery lazy load plugin, it works great, is very customizable,
and you dont have to deal with cross browser issues :
http://plugins.jquery.com/project/lazyload

The magic word is "Lazy loading". I have no experience with it but this plugin is one of the most popular solutions.

You may take a look at the following article which uses jquery.

Related

All scripts AND libraries in ONE js script?

Ok so I am in the process of building my first Javascript 'framework' or 'bootstrap' which will be implemented in combination with a single pre-processed CSS file. I am gathering my favorite content slider, smooth scroller, content slideshow, parallax elements & bg-img, sticky elements, among a few more cutting edge navigational & UI based scripts (cross-browser/platform/device/viewport compatibility and performance). My problem is when constructing my demo page with all combined elements in place loaded and active on the page... well many seeem to require a different version of Jquery to be called in order to function properly. I have managed to get them to work properly while testing by carefully reordering the jquery librarys as they are called in the of the page. Now here is my (2) part question:
How do I get all my JQuery to work properly without loading multiple versions of it (one for each script almost)
I have a sample in my portfolio which I would love to use as the example. http://www.nicholasabrams.com/ (non mobile device version). In the src for that URL you will see only (1) js and (1) css - including the jquery libraries which are ALSO included in the single .js in the begining of the file. Please don't flame me, as I am asking for help. The link above works fine now (with apple as a slight exception)... but I am just trying to eliminate any bad practices I have as I have just started as a web developer at my first large company. Thanks!!
PS: Would post a snippet but its quite a large js file as you would imagine but if you will, please inspect my src and let me know what you think because my sites first load decreased from 22 seconds to 4-7 seconds after doing the above I wish I could just include the latest version of JQuery!)
if I understand you correctly you are loading more than one jQuery library to the page (in different order)? That's a mistake - you shouldn't do that.
What you should do is make sure that the plugins you work with are compatible with the library you are working with. If they're not - wither find other plugins or fix the ones you have to support the jQuery language you are using.
You have a 2 megabyte hi-res background image, that is insane! I would scrap that and the swirl image, while it may look cool to you, it is distracting and may actually make people want to avoid your website. It makes it difficult to concentrate on the text in the middle of your screen. You don't want people to remember the swirling image, but rather your portfolio, right?
You also have 404's on the following:
http://www.nicholasabrams.com/ScrollSpy_files/result-light.css
http://www.nicholasabrams.com/example-images/testing_station.png
404's are bad for several reasons, they are a wasted resource as they slow the loading of your page, because it attempts to find something and does not find it, and, finally, they have a negative impact on your SEO, specifically Google PageRank docks you for any 404's.
Find a way to work with one version of jQuery, it will eventually bite you to have multiple versions of the library and it is a bandwidth killer to have your users load up a bunch of libraries, even if they are CDN'd.

jQuery and Preloading images?

Hey there- Semi new to javascript, a couple of questions. If I preload a bunch of images on Page-1, are they then made available in Page-2 instantly? What if Page-2 displays these images via a jQuery plugin, do the same rules apply? Thanks!
Yes, they should be available on page 2, because if you preload rollover states for navigation buttons, for example, you only need to preload them the first time the site is accessed. The images are then cached and available to subsequent pages you view on the same site.
I'm not sure about the jQuery plugin part. Do you know the specific plugins you'll be using?
I haven't done any testing on this, but I'd imagine a lot of this depended on how the user had their caching set up. Generally speaking you can pre-load images and they'll remain the cache. There's a nifty html5 feature that allows for pre-loading to help with this as well.

want to make better content display

We are developing a social networking project, in this project we are adding content , e.g. images , video,audio,link(html).
Currently we are using shadowbox.js to show it.But for better and effectiveness we want to use some other better plugin, or want to make own window for showing images and link.
Please help , what is the best solution for this project.
I want to know this is the white board quesion means programmer.stackexchange question or stackoverflow quesion?
Thanks
There are 31 here:
http://www.dreamcss.com/2009/03/31-mind-blowing-collection-of-jquery.html
You should find one or more that suits your needs.
I would suggest using colorbox.js it can be found here :
http://colorpowered.com/
It is easily styled, comes with a pleathera of options including an image slideshow, can handle iFrames, Ajax content, Images, etc, and comes with a few options for styling to begin with.
Made my own div and use that for displaying content :)

How can I avoid seeing the rendering of Cufon font replacement tool while loading a page?

I've published a website and every page has an or element with Cufon (cufon-yui.js) and sometimes while the page is loading , the visitor can see the text replacement tool doing it's job. It looks bad, some users are asking about it.
Why would that be happening if I'm using it (cufon) like anybody else and I don't' see this text rendering issue happening in most sites.
Also, there's an issue happening as well, with the Hyperlinks that are using Cufon.
Sometimes the cursor (a hand that appears for hyperlinks) disappear , it's bizarre.
Adding the following to your css should solve the issue:
.cufon-loading {
visibility: hidden;
}
use one of the google web fonts or typeface/
I've just started looking at Cufon, so I'm not sure I'm qualified to give an opinion, but I've read the IE has (or had) rendering issues and that you needed to add <script type="text/javascript">Cufon.now();</script> to the end of your body (right before the </body>. If you are running any other heavy scripts on the page, you might want to put them as low on the page as possible and place the Cufon.now() right above those scripts (place Cufon higher in priority). If that doesn't work, try hiding your Cufon elements with JS as soon as the DOM has loaded (visibility:hidden) and then unhide them when the onload event fires (though I'm not sure that's much better than the text flickering).
Use something better?: http://reisio.com/examples/webfonts/
(if you worry about distribution legality, replace your fonts with any of the numerous free clones available all over the internet)

Redbox Alternative?

I am building an app and want to have a lot of the site forms come up in a box over the screen with the background darkened out. I have seen redbox on github and it seems to do what I need it to do but I see that it hasnt been updated since 2007. Is there a new way to go about this? Any alternatives to redbox?
Thanks for your ideas!
Look at overlay effect in jQuery tools - a pretty nice library with a lots of demos. This is a collection of modern user-interface components such as tabs, tooltips, overlay, scrollable and so on. Single JavaScript file weighs only 5.72 Kb.
There is another pretty nice box plugin: jquery fancybox. It can display images, video, flash, html-content. Packed js weighs 15Kb. Very cool stuff.
we used facebox for popup the implementation and how to use popup on ajax subpages also explained http://www.spritle.com/blogs/?p=564. The ui for facebox is already given.Redbox development is stopped I think. I suggest to go for some other solution like thickbox, lightbox or any other solution if you want to apply your own style for your popup.But, in my opinion facebox is better.

Categories