JQuery What is core.js (in jQuery 3.3.1)

Viewed 3256

I just downloaded the latest version of jQuery via npm install jquery and it includes three uncompressed files namely:

dist/core.js
dist/jquery.js
dist/jquery.slim.js

I'm wondering what the core.js file is and couldn't find anything documented about it. A google search on core.js and jquery core.js don't return relevant answers.

Also, I don't see any core.min.js. So what is it? Would I ever use it?

NOTE: It uses define() which requires an AMD loader (see https://requirejs.org/docs/whyamd.html#definition ) so it can't just be included straight into an html file.

One jQuery CDN is at https://code.jquery.com, but it doesn't include core.js (from what I saw).

Looking at the code it only defines a small number of functions some of which are:

extend, each, map, slice, first, last, eq, end

It looks like these are also defined in jquery.js and jquery.slim.js.

The jQuery documentation for core at https://api.jquery.com/category/core/ doesn't match what is in the core.js file.

1 Answers

core.js is responsible for defining the jQuery namespace, as well as the prototype for jQuery objects. - How jQuery Works - An Introduction

This below may also be quite useful or at least help you get a better understanding, but to be honest the quote above i would argue is sufficient enough knowledge on the core.js file.

It’s no longer maintained with newer versions, but a few years ago Rob Flaherty created an annotated version of jQuery 1.6’s source.

jQuery v1.6 Annotated Source Docs

Core.js Annotated Source

Related