Loading image in cache using enyo.js - enyo

I need to load images of list of product in cache using enyo and then need to load it in front end (UI), which contains list of products, for mobile version of openbravo. I am new in this field, can anyone help me out in this.

There is nothing particularly special you need to do in Enyo to pre-cache the images. The main caveat is: In mobile, don't try to cache too many images. Use any standard JavaScript technique for pre-caching images. Here's one from StackOverflow:
https://stackoverflow.com/a/6990691/506361
Basically, when you get your response back with the list of items, add the code to iterate over your array/Collection and create the throw-away Img elements.

Related

Progressive page loading in ASP.NET MV3?

I'm building a website that on its frontpage has different 'lists' of stories/articles.
You can compare it to Wordpress 'latest articles', 'spotlight articles' etc.
Now every list needs to be created, and filled from the repository.
Which means, that in my controller, I first create/retrieve all the lists, add them to the ViewBag, and then return the view.
In the View i'll then foreach over the items in that list to create a visual list to be shown on the frontpage.
However, when I load the page, I first get a blank page, when the page is loaded, and then at one point everything appears.
Traditionally, you would already see the basic html, text etc, and then the dynamic area's would appear later.
Is it possible to have a similar 'progressive loading' with MVC3?
Its not so much the performance I'm worrying about but more so the user experience of seeing a blank page for several seconds on data-heavy pages.
Thanks :)
If you've got heavy pages with long loading times you might consider loading the pieces more dynamically using an ajax approach.
Your page loads, you execute the requests for the data you require and use some standard loading icon in the meantime.

Pre-loading / AJAX - best methods?

I am building a portfolio page, which contains quite anumber of images. I am pulling the image url's from a database, and creating thumbnails from the original source, and the dispaying the thumbnails. When clicked on, displaying the original full size pic.
Loading times are obviuosly affected and the site take some time before displaying anything...
I have tried putting all this in Ajax, but it seems ajax is only reqally effective if the site has initially loaded. As it is now, the site "hangs" while it waits for the on form laod work to be done.
Any ideas on putting a "please wait while iamges laod" section into the container where the iamges will eb displayed?
Thanks in advance.
Typically you create an HTTP handler that your page sends the image IDs to, something like
<img src="image-handler.ashx?id=SOME_ID" alt="..." />
The key to performance here is that you can then cache the images from this handler. You can save the generated thumbnails to disk and check for existence, and if then use something like Response.TransferFile() to send the file (or actually create the thumbnail files on creation of images, not loading them), or even better, apply output caching on the handler, with vary by param to the id key.
For the full images also you can use the same techniques. You can also in addition have some hidden images you keep setting their URLs by AJAX before clicking thumbnails, so, they are ready when a thumbnail is clicked and a full image needs to be displayed.
Those are just high level thoughts as per the amount of detail I get from the question.

VB.Net application - display a message to the user whilst the application is starting up

I have recently created an application where a lot of data is loaded into objects when the application starts up, and other data as it is required. For example if the user requests the catalogue page then it will load all the top level category data into objects of type Category. This will then stay there to be used by other users (who will therefore not have to load this data into objects) and can be altered by admin if they happen to login during the same application instance. I know this is not the most efficient solution, as pointed out below, but it works and the page load, at the moment, is not too long. It is very quick if most of the required data is already loaded into objects. It is also tailored to the business' needs - unlike other techniques such as Linq-to-SQL.
The problem I am facing is when a page is requested which requires lots of data to be displayed about different types of object. For example when a catalogue page is requested which displays information on a product which can be bought, it then loads all the products and categories (as the products make reference to the category object, not just the category name).
I would like to display a loading symbol with a message whilst all this data is being loaded into objects, so the user knows its not just in a loop or anything. Is there any way to do this? I am open to using JS / jQuery if I need to.
Thanks in advance.
Regards,
Richard
PS I am working on ways to make it more efficient - such as using HashTables or HashMaps. However this is taking time as there are so many different types of item (News, Events, Catalogue Item - Range, Collection, Design, RangeCollection, CollectionDesign, RangeCollectionDesign and RangeDesign - Users, PageViews and the list goes on).
Please correct me if I'm wrong, but I do believe that Javascript is required in order to display a "loading" image... Using server-side scriping alone would typically require an entire page load after all the content loads unless you want to start messing with IFrames.
This is a job for AJAX. A common solution to your problem is to have a small page that displays a loading icon. The page has some JavaScript that makes additional HTTP requests to the server to download the rest of the page. JQuery has a "$.ajax" method that is designed to simplify this process.
I would suggest looking at the documentation to the .ajax method in the jQuery documentation. Unfortunately, it seems to be a rather delicate process to get all the scripting code right and it takes a while to learn it all.

How to serve different cached versions of a page depending on a cookie in Drupal?

The task is relatively straightforward:
A Drupal website displays a list of articles with thumbnails. Some visitors would like to view it without images by clicking on a button/link and have that preference saved.
e.g. http://patterntap.com/collections/index/
The problem is all visitors are anonymous and given certain traffic, page cache is enabled.
My idea was to use some simple JavaScript to set a cookie, refresh the page and depending on the cookie values (or its presence/absence) display or hide the images.
Except Drupal serves cached pages quite early and the only quick way to modify the cached version that I could find is by hacking includes/bootstrap.inc and add a custom class to the body classes then hide the images with css.
A very wrong approach, I know. But I wonder if there is a way to save different versions of a page and serve the correct version?
Edit:
need to keep the same uri
the js to show/hide the images without reload and set the cookie is already in place
hook_boot() is not really called for cached pages, so can't do it via custom module
.htaccess mods?
Edit/solution:
In the end went with Rimian's suggestion. But it is possible to accomplish the task using our own cache.inc implementation as seen in the Mobile Tools module. Specifically, by extending cache.inc and updating settings.php to include
$conf['page_cache_fastpath'] = FALSE;
$conf['cache_inc'] = 'path/to/my/module/my_module_cache.inc';
So let me get this right. You wanna hide some images on a cached page if the user chooses to?
Why don't you write some jQuery or javascript and load that into your cached page with all the rest of the document?
Then, the client/browser would decide to run your script and hide images depending on some parameters you passed along with the request to that page or in the cookie? The script gets cached and only runs when you call it.
If you were hacking the bootstrap for something like that you'd really need to be rethinking what you were doing. Crazy! :)
Also take a look at cache_get and cache_set:
http://api.drupal.org/api/drupal/includes--cache.inc/6
I'm not sure I 100% understand what you are trying to do but here are my thoughts. One of your root problems is that you are trying to access what is essentially different content at the same uri.
If this is truly what you want to do, then Rimian's suggestion of checking out chache_get and chache_set may be worthwhile.
Personally, it seems cleaner to me to have your "with thumbnails" and "without thumbnails" be accessed via different uri's. Depending on exactly what you are wanting to accomplish, a GET variable my be an even better way to go. With either of these two options you would hide or show your thumbnails at the theme layer. Pages with different paths or get variables would get cached separately.
If you want the visitor to be able to switch views without a page reload, then jQuery and a cookie would probably suite your needs. This wouldn't require a page reload and switching back and forth would be quite simple.

Edit what displays in an iframe

I'm trying to display content from anther site on to mine using an iframe. I'm just wondering if its possible to only display certain parts (divs) of this external page in the iframe.
Thanks!
You could try and use some jQuery on your site to dynamically alter the styles of the external site. I did something similar with SSRS where we had an iframe containing SSRS reports which we wanted to style. We used jQuery in the master page to find the matching elements inside the frame target and alter them as required.
As long as the external site is well marked up (plenty of ids, good semantic structure) you may be able to hide/re-arrange elements as you require. You may also need to delay the jQuery execution as the frame contents may not be completely loaded by the time your JavaScript executes.
You can find a VERY simple example here.
BUT, be careful of the legalities involved with showing partial content from someone else's site. If you're presenting their site as your own or without identifying information, you could be infringing on their copyright.

Resources