Lazy loading parts of a WordPress website - wordpress

I have a WordPress website that has a form which is integrated with a CRM. And it is causing the page to load slowly even with a caching plugin (W3 Total Cache) enabled.
I was wondering whether it is possible to load a particular div after the website has been loaded?
Thanks!

You can easily achieve this with the help of CSS and javascript/jQuery.
Set Display property of that div as none until it hasn't rendered completely in the DOM as:
#divName {
display: none
}
Now, the functionality to display on complete load can be written as :
$(document).ready(function() {
$('#divName').delay(ms);
});
Note: Here, ms is count in milliseconds(1000, 2000, etc.)
I hope this will help. Cheers!

Related

mmenu wordpress plugin - can't setup position from option page

I'm using the free version of mmenu plugin for wordpress. The menu is working correctly but it opens always from the left, even if i set up another position from the option page.
If I inspect the js file "mmenu.js" it seems that the option is passed correctly as I can see it in the code this string:
extensions: { "all": ["position-top"] }
But if I inspect the HTML source there are still the classes as the menu is setup to be opened from the left: (mm-wrapper--position-left, mm-menu--position-left, ...)
I wonder if this is a known issue or just a problem of my website, and if maybe you have a possible solution.
Thanks in advance
Francesco

Prevent jQuery mobile link caching

I have a asp.net website with some header links in master page. For some of them I added link to jQuery mobile script to format those specific pages (forms) to look good on phones/tablets.
But after I load one of those pages and then click on some other page, it somehow caches the current page and although I can see the correct page being loaded for split second, it then reloads previous page. I don't know why this happens, but I know that culprit is the jQm link, because if I remove it, it works like expected (without the mobile design though).
I don't use data-role="page" attribute or anything, just classic asp.net page.
jQuery Mobile uses it's own kind of navigation model by default. It injects multiple specifically formatted pages into current page using AJAX. You probably need to disable it using code snippet below:
$( document ).on( "mobileinit", function() {
$.mobile.ajaxEnabled = false;
});
For more information check jQuery Mobile documentation navigation model and global configuration pages.

How do i avoid a flash of unstyled content (FOUC) on Google Sites

I have placed some custom HTML, CSS, and jQuery inside an HTML box in my google site. but as the page loads, the unformatted content shows for several seconds until the loading is complete. attempts to add the following:
html { visibility: hidden; }
and then turning it back on later in jQuery do not appear to work inside a Google site.
Does anyone have another suggestion?
I don't know if this works on a google site or not, but using
<body style='display:none;'>
and then in the jQuery document ready function place
$("body").show(); has worked for me.
For some reason using style on the body statement works faster than the CSS file even if the CSS file appears in the head section.

Adobe Air parent frame bridge

I tried following the tutorial at http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7f11.html#WS5b3ccc516d4fbf351e63e3d118676a3fc7-7fea but just can't get it right.
I have an app with an iFrame. Dynamically loading into the iFrame are pages from a website. To ensure any links in these pages open in the local client browser, the iFrame content needs to call a function in the parent to launch the link as desired.
So the child iFrame needs to call the following function in the parent:
function openInBrowser(url) {
air.navigateToURL(new air.URLRequest(url));
}
How can I achieve this using the bridge technique?
Greg.
Ok, I guess the good old read the instructions worked! Although not in the above page, but a link from that page... ;(
I followed the tutorial at: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e5c.html
and it worked very well!
Greg.

Counter measure if/when external CSS file is not loaded when the page did

Due to network or some other reasons, some sites do not have their css files loaded and you will see unformatted/un-layout-ed ugly page.
It happened to pages I did before also. Kind of beyond control from a developer/design point of view.
I'm thinking of something like this place at the top of the page and obvious:
/*.... header and stuff */
<body>
<h2 id="hiddennote">If you do not see this page properly, please refresh</h2>
/*.... rest of the page .... */
The external stylesheet have a definition like this:
/* other styles defined */
#hiddennote {display: none;}
Functionally I know it'll work. Any drawbacks?
Another potential drawback is that it depends on the user knowing what the page is supposed to look like. You could fix that by changing the language of the message to something like, "This page is not displaying properly! While you are free to use the content below, you may want to refresh your browser to try loading the layout and styling information." You could also include a screenshot, assuming your images are not hosted on the same troublesome network.
The obvious drawback is if the page fails to load the CSS the second time.

Resources