New user need help on understanding of 'External Library'

I am a new user to WebStorm, yet have years of experience of Java Web development.

Recently I am trying WebStorm 7.0, and is going to build a Hello World js-html project. The menu of WebStorm reminds me can define & configure the js libraries you want to use in the project, and I try to install the official library 'jQuery' and it appears in my project view now, under 'External Libraries' tag, as the snapshot shows. But this operation confuses me, how could a js lib be referenced in such way? I try to leave it as it was & call some jQuery API in the html -- of course it doesn't work, because it challenges the common sense that if you want to use a js lib, you have to explicitly refers to it by <script src="..."/>. Here is what I did after this failure: copy the jQuery.js to a project sub-directory, and refer this file explicitly in the html source. And now it works.

My Question: What is the proper way of using External Library of a WebStorm project? How about the way I have shown in the screenshot, by using <script src=""/>?

Thanks in advance.


QQ20131001-8.png

2 comments

Hello!

Javascript external libraries are used by IDE for type hinting/completion/navigation - WebStorm doesn't pass it to the browser at runtime, so you will face ReferenceErrors if the <script src="..."/> points to no-existing file or is absent. If the .js file is located inside your project and is available by URL specified in src attribute, WebStorm doesn't need it being configured as a library - all functions, etc. will be correctly resolved. But if you use http URL, for example, the script will be available to browser but not 'visible' to WebStorm, so no completion/hightlighting will be available. This is just the case when external library is needed. BTW, you can use 'download library' intention to download and configure the .js file accessed over HTTP - see http://www.jetbrains.com/webstorm/webhelp/javascript-libraries.html

0

Thank you very much, it really make sense.

0

Please sign in to leave a comment.