Explanation of Webstorm External Libraries

I read this page which explains what external libraries in Webstorm are, but I still have more questions: https://www.jetbrains.com/webstorm/help/configuring-javascript-libraries.html

Are external libraries just for code completion and production assistance? Can they be used to link libraries, for example, in index.html? (Probably not, because they were not found in the project folder).

I guess my question is what are external libraries other than what I said at the beginning?

+7
webstorm
source share
1 answer

Javascript libraries configured in Settings / Languages ​​and Structures / javaScript / Libraries (and shown as external libraries in the project window) have absolutely nothing to do with links in the <script> . The former are used by the IDE to highlight code / navigation / error counting, the latter are used by the browser at runtime. The browser knows nothing about javascript libraries configured in the IDE; the IDE does not use <script> links in your HTML files.

Let me try to clarify the situation:

Which libraries you intend to use: By default, shutdown works for all JavaScript files located under your project root. So, if you already have library .js files in your project structure, this is enough to get the completion. If they are missing and you don’t want to knock on the project with all these files, you can store them from the outside (outside your project) and configure them as libraries to make them available for WebStorm. Also note that libraries are "lightweight" compared to .js files in your project - they are considered as read-only, and checks are disabled. In addition, you can assign documentation URLs to them by providing external documentation for the library code. Thus, even if you have your library files in your project, it makes sense to add them as libraries

So, we summarize:

  • library files located next to your source files in the project structure are available for both WebStorm and browser, regardless of whether they are added to javascript libraries in the settings

  • The online library referenced by the CDN link in your HTML is available to the browser at run time, but cannot be used to complete in the IDE

  • library files hosted outside the project and configured as javascript libraries will be available for WebStorm to complete,
    but will not be loaded by the browser

+9
source share

All Articles