JS library vs Js framework

I looked at expert-exchange and other sites and videos but I am little confusing...I have some blind spots about the main differences of these two.
  1. Is the library a "tank" of functions that we can call every time that we need these?
  2. Is the framework a single function that we use to to do some event?
  3. Why the majority of libraries starts with an IIFE function?
If there is an article to explain with a plain words the main guide to build a library please post it.
Thank a lot
LVL 16
Leonidas DosasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
IIFE - this creates privacy
(function() {

Creates a scope around the function so that anything declared in that scope is private to that scope.

Library - a collection of functions that can be called together or independently to perform specific operations. Functions can be called in isolation without necessarily having to perform any configuration or initialisation (Example: jQuery)

Framework imposes a structuring on the code - you construct your code around the rules of the framework.

Simply put - when you use a library you are in control of what you use and how - with a framework - you are under the control of how the framework does things.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
If there is an article to explain with a plain words the main guide to build a library please post it.
This is pretty open ended. A library can be as simple as

function addTwoNumbers(a, b)
   return a+b;

Open in new window

If you want write a plugin for a library lie jQuery there are many tutorials on line to show you how to do this.

Bottom line - many ways to skin this cat - you would need to be more specific in terms of what you are trying to achieve.
Leonidas DosasAuthor Commented:
Thanks a lot Julian. As a matter of fact I'm trying to go one step beyond at my js knowledge studying some js libraries and frameworks at github. My problem is to understand the basics guidelines about what is performed these two things and the  logic of code construction. I read eg that jquery library returns wrapper functions to manipulate the DOM elements..and I wondering about the way that jquery is doing this.
Get Blueprints for Increased Customer Retention

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Julian HansenCommented:
The jQuery library relies on the fact that almost every jQuery function returns a jQuery object - this allows us to chain jQuery functions together.

Each function takes the input performs whatever function is required and then returns a jQuery object that gives access to the next call to a jQuery function.

A good library to look at is Datatables - it is quite comprehensive and written well.
Leonidas DosasAuthor Commented:
Maybe is a change for someone to do a beginners guide  article about libraries and frameworks in javascript. I see a lot of excellent codes that I can't determined how they structured.
Julian HansenCommented:
There is a lot of opportunity for this but the landscape is exploding so rapidly difficult to come up with something that retains relevance.

With frameworks like Angular and React (which is more of a library) along with Hybrid environments like Cordova and Appcelerator etc - JavaScript development is going exponential with new ideas coming out regularly. When one writes such an article in order for it to have practical value in terms of a "how-to" it is going to need to be quite specific in what it targets.

For instance we could narrow the focus down to DOM manipulation - but the argument there is that jQuery already has this space covered so use jQuery and make your library in accordance with jQuery guidelines.

If such an article was to be written though - what would you ideally like to see in it?
Leonidas DosasAuthor Commented:
I would like to see the follow:
1. Definition
2. General guidelines structure and design.
3. A simply example for each of these
4. An  explained example like datatables  that you posted.
Julian HansenCommented:
A simply example for each of these
Just to clarify "each" - can you give me a list
Leonidas DosasAuthor Commented:
One simly example for framework and one for library
Julian HansenCommented:
Ok - will give it some thought.
Leonidas DosasAuthor Commented:
Thank a lot. As you understood I made a indirect request to you about the article. I hope I am not adding you an adittional effort, but I think that this article is going to be usefull not only for me but and to others experts.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.