how to reference external js library in html document

I've created a new entry for jQuery 1.6.4 in the project settings and added it to the usage scope of my project. It is also listed in the project outline (under External Libraries).
Now I am unsure on how to properly reference the script in my html document.

the library lives here:  /srv_www_root/libraries/javascript/jquery_1.6.4.min.js
my project is located at: /srv_www_root/project/ and has its own virtual host

In my html <head> I have this:

<script type="text/javascript" src="http://localhost/libraries/javascript/jquery_1.6.4.min.js"></script>
<script type="text/javascript" src="scripts/banner.js"></script>


... but all jQuery methods in the banner.js are marked as unresolved.

Whats the proper way to set this up?
Do I have to always create duplicates of js libraries in my project directory?

3 comments

I have exactly the same question. Anyone?

0

Here is what you can do:
1) When the caret is at "http://localhost/libraries..." link, press Alt+Enter to invoke a quick fix. Choose "Download library". This will automatically create a global jquery library out of your link. Naturally jquery-1.6.4.js must be available via http at this point.
2) Open banner.js. Right click and choose "Use javascript library"/"jquery 1.6.4.".
That's the easiest and the fastest way to set it up.
You can also set up jquery 1.6.4 for the whole project (without a need to specify it's use in every .js file). Open Settings/JavaScript/Libraries/Usage Scope. Choose either project or project's root directory. Select jquery 1.6.4. Click "Do Not Override" (overriding may drop other library dependencies if you have specified any).
I hope it helps.

0

I forgot to mention that for development purposes you have to use a non-minified JS library version. If you would refer to CDN, this would be done automatically but for you local server you have to keep both versions or create a global JS library with non-minified version manually.

0

Please sign in to leave a comment.