The purpose for creating a library is to reduce headaches from refactoring our code. In this tutorial I go over a super simple way to make your own library that is really similar to jQuery.
The following code will create a global variable accesible after the code is executed called myWindowGlobalLibraryName.
We need that our library. Create a directory demo and run following command in it. But this approach its not recommended.
Mkdir package_name cd package_name After determining the name of your package youll need to know whether its going to be scoped ie package vs. 1 Create the basic structure. Run following command to initialise a project.
As web developers it is our job to create compelling websites that increase user engagement. For that we will be create two utility functions into two separate files in our source folder. I am using a –y to initialize it with default options.
Identify the purpose of your library. I hope you like it. In mainjs.
We will add functions to our library here. Lets imagine you have a website that is serving a downloadable product to. Instead of it you can create a new JS file to run your library code.
This article will show how to squeeze the most out of the modern build toolchain. Npm init -y. Create a directory for your package on the command line where package_name is your actual package name.
Now open our project in code editor and create a new file called appjs you can call it anything you want. Function window You can enable the strict mode commenting the following line use strict. The above command will create a packagejson in your project root.