Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, October 17, 2012

Make Your Pages Load Faster

Here is some tips which will make your page load faster

Avoid table layouts and use Div.

Don't use images to display text.

Call up your images through css if possible.

Use contextual selectors

Use shorthand css properties.

Remove white space, line breaks, and commented tags.

Use relative path instead of absolute

Remove unnecessary Meta tags and Meta contents.

Put you css and JavaScript in separate files.

Use '/' and the end directory links.

Use compressed version of css and JS files

Enable compression on your IIS while deploying the site on IIS.

Thursday, October 11, 2012

How to check Complete Page Load by JavaScript

In a client-side application. your application is initializing any control or populating a large amount of data in your control. 

You need to execute a script after DOM is ready and ALL of the other assets in the page (images, etc.) are loaded.

Use window.onload event. This event will not fire until both DOM is ready and ALL of the other assets in the page (images, etc.) are loaded.

Once your page is loaded completely this event automatically fired.

There is other way around put onload event in your body tag.

If you need to execute some script after your page load in your js file. 

window.onload = function(){

  // Write your script
  alert("Page is loaded completely");

}