I have a webpage to be hosted on a mobile device which is both Wi-Fi and 3G capable.
As 3G data may cost money and is generally limited, i want to minimize the amount of uploaded data by the device. So what I basically want to do is the following:
Try to load the jquery scripts online:
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.13/jquery-ui.min.js"></script>
And only if that fails to load correctly (e.g. if the user is not connected to the internet, just to the phone), load it from a local copy:
<script type="text/javascript" src="js/jquery-copy.js"></script>
The same applies for css files.
I've thought about having a <script id="loadable"></script>
and then use $("#loadable").load("url");
but obviously I depend on jquery to be loaded first, which is the file to be minimized.