I am looking to create a system which on signup will create a subdomain on my website for the users account area.
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
I'm using php and javascript and what i want to do is to load the different sections of a web page at different time such that first my header and side slider loads up and then my middle content. And also, when user scrolls down then only the images loads up.
You can use jQuery to asynchronously load contents to your page very easy.
ReplyDeletehttp://api.jquery.com/load/
But you will not win performance on that, unless you have very big blocks of content you want to load in portions.
I don't think that is the purpose of PHP... nor does it work like that.
ReplyDeleteI wouldn't intentionally delay load time, so using jquery .load() just for the sake of a visual effect is bad practice. If you just want the visual effect of loading the parts at different times you can do the following:
In the head, add the following script. I would add it right after or before your style sheets.
var thehtml = document.getElementsByTagName('html')[0];
thehtml.className = 'loading';
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function removeClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}
window.onload = function() {removeClass(thehtml, "loading")}
Style the .loading class:
.loading #header,
.loading #sidebar {opacity: 0}
#header,
#sidebar {opacity: 1; transition: all 3s ease-in-out;}
This will cause the header and sidebar to fade in once the loading class is removed. If your middle content consists of all images, you can use a "lazy loader" like lazy karl. http://www.karlsteltenpohl.com/blog/,56,
In general I think all lazy load plugins are bad for performance as you have to rely on a scroll event, which means javascript runs a function every time the user scrolls the page.
Additionally if you want to have more control over the timing and order of "loading" you can use setTimeout() inside of the window.load function to have the elements load at different times.
If you choose this solution there will be alot more CSS involved and that will depend on your individual layout and how you've coded it.