title: prevent loading JQuery more than once
body: <p>I'm new to JQuery-Mobile.</p>
  
  <p>I have created a master page in which i have included few links of jquery mobile script and css. 
  In master page I'm loading another page into a selected div using ajax but script of master page is not accessible in loaded page. so i need to load again script in loaded page.</p>
  
  <p>This increase load time, can anyone help me out to resolve this.</p>
  
  <p>Any suggetion will be helpful, Thanks.</p>
  
  <p><strong>Edited</strong></p>
  
  <p>Master Page code. In this page there is a div having Id=>"mainContent". In this div i'm trying to load my another page on click of anchor having id "link1" or "link2". </p>
  
  <p>on click of link1 i'm calling ajax and on click of link2 loading on given target.</p>
  
  <p>in both case it works fine if all script is included in loaded page.</p>
  
  <pre><code>&lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;%@ taglib prefix="sj" uri="/struts-jquery-tags"%&gt;
  &lt;%@ taglib prefix="sjm" uri="/struts-jquery-mobile-tags" %&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="initial-scale=1 , maximum-scale=1"&gt;
  
  &lt;script src="../resources/template/js/base/jquery-1.7.2.min.js"&gt;&lt;/script&gt;
  &lt;link type="text/css" href="../resources/jquery.window.css" rel="stylesheet"&gt;
  &lt;script type="text/javascript" src="../resources/jquery.windowAlt.js"&gt;&lt;/script&gt;
   &lt;script src="../resources/template/js/base/jquery.ui.core.min.js?s2j=3.3.3" type="text/javascript"&gt;&lt;/script&gt;
   &lt;script src="../resources/template/js/plugins/jquery.subscribe.min.js" type="text/javascript"&gt;&lt;/script&gt; 
   &lt;script src="../resources/template/js/struts2/jquery.struts2-3.3.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
   &lt;script type="text/javascript"&gt; 
      $(function() {
          jQuery.struts2_jquery.version = "3.3.3";
          jQuery.scriptPath = "../resources/template/";
          jQuery.ajaxSettings.traditional = true;
          jQuery.ajaxSetup({cache : false});
          jQuery.struts2_jquery.require("js/struts2/jquery.ui.struts2-3.3.3.min.js");
      }); 
   &lt;/script&gt;
   &lt;link type="text/css" href="../resources/template/themes/flick/jquery-ui.css?s2j=3.3.3" rel="stylesheet" id="jquery_theme_link"&gt;
  &lt;script src="../resources/template/js/plugins/jquery.mobile-1.1.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="../resources/template/js/struts2/jquery.mobile.struts2-3.3.3.js" type="text/javascript"&gt;&lt;/script&gt;  
  &lt;link rel="stylesheet" href="../resources/template/js/plugins/jquery.mobile-1.1.1.min.css" /&gt;
  
  &lt;title&gt;IDP-Dashboards&lt;/title&gt;
  &lt;SCRIPT type="text/javascript" &gt;
   function pageRefresh() {
       location.reload(); //Reload the current page.
   }
   $(document).ready(function(){
       if ($('body').find('[data-role="header"]').width()&lt;400) {
       $('#home_img').attr('src','../resources/img/icon_home_small.png');
          $('#logout_img').attr('src','../resources/img/icon_logout_small.png');
       }
       $(window).on('resize',function() {
       if ($('body').find('[data-role="header"]').width()&lt;400) {
          $('#home_img').attr('src','../resources/img/icon_home_small.png');
          $('#logout_img').attr('src','../resources/img/icon_logout_small.png');
      }else{
          $('#home_img').attr('src','../resources/img/icon_home.png');
          $('#logout_img').attr('src','../resources/img/icon_logout.png');
      }
       });
   });
  
  
   $(document).on('click', '#link1', function(){
       alert("here...");
       $.ajax({
              async : false,
              type: 'POST',
              url: "./getMobileDashboard",
              data : {
                  //"mode" : "viewUserThumbnails",
          },
              success : function (msg) {
                   $("#mainContent").html(msg);
              }
          });
      });
  &lt;/SCRIPT&gt;
  &lt;link href="../resources/css/ApplicationStyleSheet.css" rel="stylesheet"    type="text/css"&gt;
  &lt;/head&gt;
  &lt;body id="body"&gt;
  &lt;div data-role="page" id="dashboardPage"&gt;
  
      &lt;div style="width: 100%"&gt;       
      &lt;%-- &lt;sj:a button="true" id="link1" href="getMobileDashboard" targets="mainContent" style="float:right;"&gt;Dashboards&lt;/sj:a&gt; --%&gt;
      &lt;%-- &lt;sj:a button="true" id="link1" href="#" onclick="test();" &gt;Dashboards&lt;/sj:a&gt; --%&gt;
      &lt;sj:a button="true" id="link1" href="#" &gt;Dashboards&lt;/sj:a&gt;
      &lt;/div&gt;
  
      &lt;div style="width: 100%"&gt;
      &lt;sj:a button="true" id="link2" href="getMobileDynamicForms" targets="mainContent" style="float:left;"&gt;Forms&lt;/sj:a&gt;
      &lt;/div&gt;
  
      &lt;div data-role="content"  id="mainContent" style="padding: 0px;"&gt;   &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is sample page which i'm loading on click of link1 to div having is "maincontent"</p>
  
  <pre><code>&lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;%@ taglib prefix="sj" uri="/struts-jquery-tags"%&gt;
  &lt;%@ taglib prefix="sjm" uri="/struts-jquery-mobile-tags"%&gt;
  
  &lt;%-- &lt;script src="../resources/template/js/base/jquery-1.7.2.min.js"&gt;&lt;/script&gt;
  &lt;link type="text/css" href="../resources/jquery.window.css"rel="stylesheet"&gt;
  &lt;script type="text/javascript" src="../resources/jquery.windowAlt.js"&gt;&lt;/script&gt;
  &lt;script src="../resources/template/js/base/jquery.ui.core.min.js?s2j=3.3.3" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../resources/template/js/plugins/jquery.subscribe.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script  src="../resources/template/js/struts2/jquery.struts2-3.3.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(function() {
          jQuery.struts2_jquery.version = "3.3.3";
          jQuery.scriptPath = "../resources/template/";
          jQuery.ajaxSettings.traditional = true;
          jQuery.ajaxSetup({
              cache : false
          });
          jQuery.struts2_jquery
                  .require("js/struts2/jquery.ui.struts2-3.3.3.min.js");
  
      });
  &lt;/script&gt;
  &lt;link type="text/css"
      href="../resources/template/themes/flick/jquery-ui.css?s2j=3.3.3"
      rel="stylesheet" id="jquery_theme_link"&gt;
  &lt;link type="text/css" href="../resources/complex/css/complex.css"
      rel="stylesheet" id="jquery_theme_link"&gt;
  &lt;link type="text/css" href="../resources/jquery.window.css"
      rel="stylesheet"&gt;
  &lt;script src="../resources/complex/js/layout.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../resources/complex/js/complex.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../resources/complex/js/layoutui.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="../resources/jquery.windowAlt.js"&gt;&lt;/script&gt;
  
  &lt;link href="../resources/css/front.css" rel="stylesheet" type="text/css"&gt;
  &lt;link href="../resources/css/common.css" rel="stylesheet"
      type="text/css"&gt;
  &lt;link href="../resources/css/elements.css" rel="stylesheet"
      type="text/css"&gt;
  &lt;link href="../resources/css/extended.css" rel="stylesheet"
      type="text/css"&gt;
  &lt;link href="../resources/css/setup.css" rel="stylesheet" type="text/css"&gt;
  &lt;link href="../resources/css/dStandard.css" rel="stylesheet"
      type="text/css"&gt;
  
  &lt;script
      src="../resources/template/js/plugins/jquery.mobile-1.1.1.min.js"&gt;&lt;/script&gt;
  &lt;script
      src="../resources/template/js/struts2/jquery.mobile.struts2-3.3.3.js"
      type="text/javascript"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet"
      href="../resources/template/js/plugins/jquery.mobile-1.1.1.min.css" /&gt; --%&gt;
  
  
  &lt;style&gt;
   .box { position: relative; float: left;  }
  &lt;/style&gt;
  &lt;link href="../resources/css/ApplicationStyleSheet.css" rel="stylesheet"    type="text/css"&gt;
  &lt;div data-role="content"&gt;
      &lt;div data-role="fieldcontain"&gt;
          &lt;div id="dashboardContainer" &gt;
              &lt;s:iterator value="dashboardprivilege"&gt;
                  &lt;div class="box" align="center"&gt;
                      &lt;a style="text-decoration: none;" href="javascript:void(0)"
                          onclick="viewDashboards('&lt;s:property value="id" /&gt;','&lt;s:property value="title" /&gt;','&lt;s:property value="dashboardType"/&gt;');"
                          rel="external"&gt;
                              &lt;img src="../niv-images/&lt;s:property value="imageName" /&gt;" width="200px;"
                                  height="150px"&gt;&lt;div style="width:210px;padding-top: 5px;height: 50px;overflow: hidden;"&gt;&lt;span&gt;
                                  &lt;s:property value="title" /&gt;
                                  &lt;/span&gt;&lt;/div&gt;
                      &lt;/a&gt;
                  &lt;/div&gt;
              &lt;/s:iterator&gt;
              &lt;s:iterator value="dashboards"&gt;
                  &lt;div class="box" align="center"&gt;
                      &lt;a style="text-decoration: none;" href="javascript:void(0)" onclick="viewDashboards('&lt;s:property value="id" /&gt;','&lt;s:property value="title" /&gt;','&lt;s:property value="dashboardType"/&gt;');"  rel="external"&gt;
                      &lt;img src="../niv-images/&lt;s:property value="imageName" /&gt;" width="200px;" height="150px"&gt;
                      &lt;div style="width:210px;padding-top: 5px;height: 50px;overflow: hidden;"&gt;&lt;span&gt; &lt;s:property value="title" /&gt; &lt;/span&gt;&lt;/div&gt;
                      &lt;/a&gt;
                  &lt;/div&gt;
              &lt;/s:iterator&gt;
              &lt;span class="stretch"&gt;&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;SCRIPT type="text/javascript"&gt;
  $(document).on('pageshow', '#dashboardPage', function(){
  
              });
  
      function serchDashboard() {
          var searchFile = $('#searchFiles').val();
          $.ajax({
              type : "POST",
              url : "mobileSearchView?searchFiles=" + searchFile,
              success : function(result) {
                  $('#data').html(result);
              }
          });
      }
  
      function viewDashboards(id, title,dType) {
          if(dType == '3') {
              url = "viewPortlet?id="+ encodeURIComponent(id) ;
          }else {
              url = "processjstree?id=" + encodeURIComponent(id) + "&amp;mode="+ encodeURIComponent("loadViewSWF");
          } 
          winOpen(url, title);
          return false;
      }
  
      function winOpen(link, t) {
          var sw = window.screen.availWidth;
          var nsw = sw - 50;
          link += "&amp;screenWidth=" + nsw;
          $.window({
              title : t,
              url : link,
              showModal : true,
              modalOpacity : 0.5,
              maximizable : false,
              createRandomOffset : {
                  x : 200,
                  y : 150
              },
              bookmarkable : false,
              onShow : function(wnd) {
              }
          });
      }
  
      function pageRefresh() {
          location.reload(); //Reload the current page.
      }
  
      $(document).ready(function(){
          $width3 = $('#dashboardContainer').width();
          $(".box").css("width",220+((((($width3/220)%1)*220))/Math.floor($width3/220)));
  
  
          $(window).on('resize',function() {
              $width2 = $('#dashboardContainer').width();
              $(".box").css("width",220+((((($width2/220)%1)*220))/Math.floor($width2/220)));
                  }).resize();
      })
  &lt;/SCRIPT&gt;
  </code></pre>
  
  <p>Page is loading but all content is not loading properly....</p>