AJavaScript library is alibrary of pre-writtenJavaScript code that allows for easier development of JavaScript-based applications,[1] especially forAJAX and otherweb-centric technologies.[2] They can be included in a website by embedding it directly in the HTML via a script tag.
With the expanded demands forJavaScript, an easier means for programmers to develop such dynamic interfaces was needed.[3][4] Thus, JavaScript libraries and JavaScript widget libraries were developed, allowing for developers to concentrate more upon more distinctive applications ofAjax.[5] This has led to other companies and groups, such asMicrosoft andYahoo! developing their own JavaScript-based user interface libraries, which find their way into the web applications developed by these companies.[6] Some JavaScript libraries allow for easier integration of JavaScript with other web development technologies, such asCSS,PHP,Ruby, andJava, while others provide utilities, often in the form of JavaScriptfunctions, to make repetitive and complex tasks less taxing.[7][8] Many libraries include code to detect differences between runtime environments and remove the need for applications to allow for such inconsistencies.[citation needed]
Almost all JavaScript libraries are released under either apermissive orcopyleft license to ensure license-free distribution, usage, and modification.[9]
Some JavaScript libraries, such asAngular, are classified asframeworks since they exhibit full-stack capabilities and properties not found in general JavaScript libraries.[10][11]
JavaScript-based web application frameworks, such asReact andVue, provide extensive capabilities but come with associated trade-offs. These frameworks often extend or enhance features available through native web technologies, such asrouting,component-based development, andstate management. While native web standards, including Web Components, modern JavaScript APIs like Fetch and ES Modules, and browser capabilities likeShadow DOM, have advanced significantly, frameworks remain widely used for their ability to enhance developer productivity, offer structuredpatterns for large-scale applications, simplify handling edge cases, and provide tools for performance optimization.[12][13][14]
Frameworks can introduce abstraction layers that may contribute to performance overhead, larger bundle sizes, and increased complexity. Modern frameworks, such as React 18 and Vue 3, address these challenges with features like concurrent rendering, tree-shaking, and selective hydration. While these advancements improve rendering efficiency and resource management, their benefits depend on the specific application and implementation context.
Lightweight frameworks, such asSvelte and Preact, take different architectural approaches, with Svelte eliminating the virtual DOM entirely in favor of compiling components to efficient JavaScript code, and Preact offering a minimal, compatible alternative to React. Framework choice depends on an application’s requirements, including the team’s expertise, performance goals, and development priorities.[12][13][14]
A newer category of web frameworks, including enhance.dev, Astro, and Fresh, leverages native web standards while minimizing abstractions and development tooling.[15][16][17] These solutions emphasizeprogressive enhancement,server-side rendering, and optimizing performance. Astro renders static HTML by default while hydrating only interactive parts. Fresh focuses on server-side rendering with zero runtime overhead. Enhance.dev prioritizes progressive enhancement patterns using Web Components. While these tools reduce reliance on client-side JavaScript by shifting logic to build-time or server-side execution, they still use JavaScript where necessary for interactivity. This approach makes them particularly suitable for performance-critical and content-focused applications.[12][13][14]
Allnpm packages are JavaScript libraries, but not all libraries are packages. Npm serves as a package manager for packages used inNode.js runtimes.[18][19] However, some npm packages offerCDN support for use of the library in both Node.js runtimes as well as the browser.[20]