Hi, Chrisss, Maybe $.getScript is what you looking for.
say, there is a hello.js with content: alert("hello"); when you invoke $.getScript("hello.js") , scripts in hello.js will be eval and execute. for more details about $.getScript you can checkout the api doc On Jul 21, 12:57 am, Chrisss <[EMAIL PROTECTED]> wrote: > Hello, > > I was wondering if jQuery can be used to load javascript dynamically, > on an as-needed basis. Here is the problem I have: > > I want to load a page with as little javascript as possible. When > someone clicks on an item that requires some javascript functionality, > I want it to load a javascript function from an external file and then > execute it. > > While there is some simple javascript I've found that can do this kind > of thing by appending the script to the DOM, it can't do things in > order. For instance, I want to load the function, and then execute it. > To do so, the javascript has to have some way to check if the funciton > exists. I don't like the idea of doing a time-out loop, so I was > wondering if jQuery has something built in for this kind of thing. > > Thank you! > Chris