WebStorm JavaScript libraries question

Hi all,

I'm testing the new WebStorm version and love it :-)

But one thing drives me crazy - the JavaScript libraries.
A cool feature and works very well in the WebStorm IDE.

But I can't understand why it doesn't work while testing in a browser (Firefox or Chrome).

Here is what I'm doing:
1. Added (downloaded) jQuery 1.9.1 as Global JavaScript library
2. Added a local JavaScript file, that uses jQuery (code completition for jQuery works fine)
3. Added Index.html to my project and included the local script on the top, in the head section
4. Now when I preview or debug the Index.html in a browser (Firefox or Chrome) I always get following error:
    Uncaught ReferenceError: $ is not defined
    i.e. jQuery has not been loaded

When I manually add a local copy of jQuery to the project (i.e. not using it as WebStorm JavaScript library)
and include it in the Index.html file it works as expected.

Any ideas ? What is wrong with my setup regarding jQuery as WebStorm JavaScript library?

Best,
arturb

3 comments

I believe, I misunderstood the concept of the JavaScript libraries.

They are obviously only for the WebStorm IDE and we must still include them in the HTML file.

But when I include them hardcoded in the HTML file I don't really see the benefit of using them as libraries.

By the way: when I have both (i.e. library and hardcoded inclusion) which version does
WebStorm use for autocompletion?

Regards,
arturb

0

The purpose of libraries in the IDE is for autocompletion. The advantage is that you can assign a library to only a few files, so the autocomplete box does not include all possibilities in all files at once (limiting the number of autocomplete options). This way, you do not 1000's of options in your autocomplete box but only those included in the library you actually use.
This is, afaic, the only purpose to libraries.

0

Hi,

Yes, you need a reference index.html to the jquery.js so browser can fetch (from server or local file) and use the resource as usual, because WebStorm libraries are something that browser is completely unaware of :)

Libraries is basically the way to organize the code in the IDE. Guys, please take a look at http://blog.jetbrains.com/webide/2013/03/javascript-libraries-improvements-in-webstorm-6/ for more details.

Kirill

0

Please sign in to leave a comment.