0

I have a UIWebView app and I'm loading a website built with PHP, jQuery and Ajax. I have a few external jQuery plugin files that I call, along with some images.

EX: <script type="text/javascript" src="http://www.mydomain.com/jquery.easing.1.3.js"></script>

This makes the app load somewhat slowly... Is it possible to put the jquery.easing.1.3.js file into my "Supporting Files" folder within Xcode and then call the plugin on my website by doing something like:

<script type="text/javascript" src="file://supporting_files/jquery.easing.1.3.js"></script>

If so, what would be the extension to grab these files from my app?

EDIT (ADDITIONAL CODE):

In my PHP file:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> (along with other external files)

<script type="text/javascript">
$(document).ready(function(){   
    $('#body').fadeIn(500);
});
</script>

<body id="body>

So the page fades in when it is loaded... Obviously, this requires jQuery, and the app won't reveal the site when I try to inject jQuery...

In Xcode:

- (void)viewDidLoad
{

    [super viewDidLoad];

    //load URL into webview
    [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL
                                URLWithString:@"http://mydomain/file.php"]]];

}
tcd
  • 1,585
  • 2
  • 17
  • 38
  • This answer might be worth looking at ... http://stackoverflow.com/questions/9279968/dynamically-loading-javascript-files-in-uiwebview-with-local-cache-not-working – Tomas McGuinness Oct 03 '12 at 15:38

1 Answers1

1

Have you tried JS Injection? You could use UIWebView's stringByEvaluatingJavaScriptFromString method and load local JS files. There's a tutorial I googled for. Here it is: http://www.ziconic.com/2010/10/javascript-injection-using-uiwebview.html

Ravi
  • 7,929
  • 6
  • 38
  • 48
  • I was just looking at this, I found this tutorial: http://www.altinkonline.nl/tutorials/xcode/uiwebview/load-jquery-in-uiwebview/ – tcd Oct 03 '12 at 15:36
  • I've discovered that this doesn't work for me... I need jQuery to load as the page is loading... – tcd Oct 03 '12 at 18:13
  • Both of the links are dead :( – narner Apr 26 '16 at 14:21