initializing jquery makes page load very slow

Posted on 2010-09-23
Last Modified: 2012-05-10
I have an html document which has a 1 column table holding  jquery datepicker(see attached code).

When I simply attach the datepicker using:

               //code lines 31 onwards

the table loads quikcky, but when I extend the datepicker functionality as follows:

                  $(this).datepicker('option', {dateFormat: 'dd/mm/yy'});
                  $(this).datepicker('option', {autoSize: true });
                  $(this).datepicker('option', {showButtonPanel: true });
                  $(this).datepicker('option', {onClose: function(dateText, inst) {
                              //close handler
                              //checkAndUpdateDate(dateText, inst);
                  $(this).datepicker('option', {onBlur: function(dateText, inst) {
                              //blur handler
                              //checkAndUpdateDate(dateText, inst);
the page takes a long time to load and if too many rows are used, thepage script freezes.

How can I customize the behaviour of the datepicker without causing a delay?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link type="text/css" href="css/sunny/jquery-ui-1.8.4.custom.css" rel="stylesheet" />	
<script type="text/javascript" src="assets/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="assets/jquery-ui-1.8.4.custom.min.js"></script>

<script type="text/javascript">
		var tbody = document.getElementById('tbod');
		for (var i = 0; i < 150; i++){
			var tr = document.createElement('tr');
			var tdDate = document.createElement('td');
			var tdInput = document.createElement('input');
			tdInput.setAttribute("id", 'dpicker' + i);
			tdInput.className = 'date-pick';

			$(this).datepicker('option', {dateFormat: 'dd/mm/yy'});
			$(this).datepicker('option', {buttonText: 'Velg dato'});
			$(this).datepicker('option', {autoSize: true });
			$(this).datepicker('option', {showButtonPanel: true });
			$(this).datepicker('option', {onClose: function(dateText, inst) {
					checkAndUpdateDate(dateText, inst);
			$(this).datepicker('option', {onBlur: function(dateText, inst) {
					checkAndUpdateDate(dateText, inst);


//		$('.date-pick').datePicker({clickInput:true})



	<table class="tab" width="100" border="1">
        		<th id="head-date" class="date" scope="col">Date</th>

		<col width="100px" />
	    <tbody id="tbod">


Open in new window

Question by:Viking46
LVL 15

Expert Comment

ID: 33748439
What browser are you using? IE 6 is particularly slow when doing anything with javascript, try loading the "slow" page in the latest version of firefox or chrome and see if it's any faster.
LVL 51

Accepted Solution

HainKurt earned 500 total points
ID: 33748463

Author Closing Comment

ID: 33748794
Thank you Crisco 96, I am using FF and it wasn't a browser issue.

Thank you HainKurt, setDefaults is what I was looking for.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now