javascript - conditional loading of jquery and jquery UI issues -



javascript - conditional loading of jquery and jquery UI issues -

the next works perfectly:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script>!window.jquery && document.write(unescape('%3cscript src="/scripts/jquery-1.6.2.min.js"%3e%3c/script%3e'))</script>

however, doing same jquery ui (but alter window.ui - should right i'm not 100% sure) not work - loads local version every time not when cdn file not available (per firebug):

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script> <script>!window.ui && document.write(unescape('%3cscript src="/scripts/jquery-ui-1.8.14.min.js"%3e%3c/script%3e'))</script>

it load local version when network unavailable when cdn version loaded (which means unnecessary double loading).

?

your load check needs little tweak. jquery ui creates ui object under jquery (or $) object, not under window. window.ui should window.jquery.ui, this:

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script> <script>!window.jquery.ui && document.write(unescape('%3cscript src="/scripts/jquery-ui-1.8.14.min.js"%3e%3c/script%3e'))</script>

javascript jquery jquery-ui conditional

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -