Skip to content Skip to sidebar Skip to footer

Webstorm: How Can I Link The Html To An Installed Js Library?

I'm working with WebStorm. I used it's built-in feature to install jQuery. It now appears in the External Libraries section of the project. But I can't link my Html files to it (&l

Solution 1:

You can't. Javascript libraries configured in Settings/Languages&Frameworks/JavaScript/Libraries (and shown as external libraries in the Project window) have absolutely nothing to do with references in <script> tag. The former are used by IDE for code completion/navigation/error highlighting, the latter are used by browser in runtime. Browser knows nothing about javascript libraries configured in IDE, IDE doesn't use <script> references in your HTML files. You need to either specify a CDN link as URL (like "http://code.jquery.com/jquery-2.0.0.min.js") or copy the file downloaded by WebStorm from ~/.WebStorm9/system/extLibs to your project directory and specify a path relative to your .html file.

Let me try to clear the things up. What libraries are supposed to be used for: by default, completion works for all JavaScript files located under your project root. So, if you do already have the library .js files in your project structure, it's enough to get the completion. If they are missing, and you don't like to clatter your project with all these files, you can store them externally (outside of your project) and configure them as libraries to make them available to WebStorm. Note also that libraries are 'light-weight' as compared to .js files in your project - they are treated read-only, have the inspections turned off. Plus, you can assign documentation URLs to them, enabling external documentation for library code. So, even if you have your library files in your project, it might make sense to add them as libraries

So, to summarize:

•library files placed next to your sources files in the project structure are available to both WebStorm and browser, whether or not they are added to javascript libraries in Settings

•online library referenced via CDN link in your HTML is available to the browser at runtime, but can't be used for completion in the IDE

•a library files placed outside of the project and configured as javascript libraries will be available to WebStorm for completion, but won't be loaded by a browser

Post a Comment for "Webstorm: How Can I Link The Html To An Installed Js Library?"