advagg drupal module breaking my js file I am using advagg module to improve my website performance and I also using date picker jquery UI function for date functionality.

I have datePicker  intialization $( "#datepicker" ).datepicker(); . It works perfectly, I can Even see the calender but when I am selecting the date, I don't see any alert. 

for Some reason On datepicker function onSelect is not working when I have advagg enabled.

 jQuery('#datepicker').datepicker({
    onSelect: function(dateText, inst) {
        alert(dateText);
        glImgExpiry = dateText;
      }
});


If I disabled advagg, It works without any problem and I can see alert(dateText).
This is happening when I am configuraing advagg to my dev/test , In my local I am not able to configure correctly because I only see per file setting for jscompression and other settings in my dev/test.So sadly, I am not able to reproduce same issue in my local and it is breaking in my test/dev environment. 

I know the information, I am giving is not sufficient to get the issue/ problem I am describing. I am just hoping some one might have faced same kind of issue and can help me resolve this problem. 

EDIT

As suggested I have tried putting the datepicker onSelect function inside drupal.behavior

(function($) {
    //add drupal 7 code
    Drupal.behaviors.myfunction = {
        attach: function(context, settings) {
//end drupal calls

            jQuery(document).ready(function() {
                jQuery('#gl_img_datepicker').datepicker({
                    onSelect: function(dateText, inst) {
                        alert(dateText);
                     }
                });
//some jquery goodness here...
            });

        }};
})
        (jQuery);


But I still dont see the alert(dateText); in the page. 

Thanks your help is really appreciated.
You do not need to add document.ready to a behavior.
Read about drupal behaviors HERE or at a good blog post HERE.
Basically I think Drupal adds a document.ready which calls all the behaviors. The behaviors are also called after an ajax call is returned (sending the new content returned by the ajax to the behaviors via the context variable). Which is why we use the context variable in the jquery selector.
Your javascript should probably look like this.  

(function ($) {
  Drupal.behaviors.myfunction = {
    attach: function (context, settings) {
      $('#gl_img_datepicker', context).datepicker({
        onSelect: function(dateText, inst) {
          alert(dateText);
        }
      });
    }
  };
})(jQuery);