AngularJs with ocLazyLoad and webpack
Recently i got chance to work with 2 technologies. One is the most popular framework and another is the latest version of the later one. Its AngularJS and Angular2. Most interesting thing was, i had to write the entire code in ES6. Intresting?
Scenario
The scenario is interesting. Most SPA in AngularJS face a big challenge. As the project grows it will become slow to load. The modules, libararies. Everything need to be loaded in the initial stage. In this scenario lazy loading comes in to handy. The modules and libraries only be loaded whenever they were required and it's dynamically added to the application. Though Angular2 supports lazy loading by dafault, AngularJS doesn't support lazy loading by default. And also angular need to register the directives, controllers etc. It will create so many requests for a single module. If we could bundle all the required templates, js ,css into a single file we could reduce the number of requests send to the server for retrieving the files.
We will use ocLazyLoad for lazily load the modules and dynamically register the controllers. We are going to use webpack for bundling.
Most popular Javascript framework. One of the fast developing community.
Webpack is a bundling tooll used to bundle js, html, css files together . It also minifies and uglifies it. There are other options like systemjs and jspm . But webpack is one of my favourite and it comes with a development server.
ocLazyLoad is angular module with supports lazy loading the modules. Requirejs is another option. But requirejs only loads the modules , it doesn't dynamically register the angular components. On the other hand oclazy helps to dynamically register the angular components.
That's said, you could find the code at github. Fork it use it and let me know the results.
Folder structure
Webpack.config
The config file for webpack. We will define the loaders and the bundling startegy in here. For js loader we will be using babel. Note that we are excluding the node_modules and the vendor folder. Vendor folder will be used store third-party frameworks which may cause problem while we load using the babel. Also we are loading the jquery and loadsh and use it as global provider, so that we could access it from anywhere. For styling you could use css or scss .
build
The build folder where the bundles generated. The index file will be located here.
src
Actual code resides here.
src/app.js
The main entry file where we bootstrap and inject the dependencies. The base.scss will loaded here.
Installation
For installation clone the repo. Inside the project folder run `npm install`.
Then run `npm run dev` for runing the development server. Access the app at `localhost:8080`
For building the app run `npm run build`, which will create the bundles for the app.
Update(13 Nov 2017): Added lot of features.
Update(13 Nov 2017): Added lot of features.
- HTML templates will be lazy loaded as bundles
- Added separate config files for build and developement
- Removed build folder, will be created on build process only. All assets will copied to build from src
- Changed font importing moved to base.scss from config.scss to avoid style breahdown
- gzip support added in build
Comments
AngularJS Training in Tambaram
AngularJS Training in Porur
AngularJS Training in Velachery
Angularjs Training in chennai
AngularJS Training in T Nagar
Web Designing Training in OMR
Web Designing Training in T Nagar
Web Designing Training in Tambaram
AngularJS Training in Chennai
Web Designing Course in chennai
AngularJS Course in Chennai
Web Designing training in chennai
AngularJS Training in Anna Nagar
Web Designing Training in Velachery
AngularJS Training in T Nagar
Web designing Training in Tambaram
Great info. The content you wrote is very interesting to read. This will loved by all age groups.
Angularjs Training in Chennai
Angularjs Course in Chennai
Web Designing Course in Chennai
PHP Training in Chennai
ccna Training in Chennai
gst training in chennai
ReactJS Training in Chennai
Angularjs Training in Chennai
Angularjs Course in Chennai
Google Cloud Training in Bangalore
Azure DevOps training in Bangalore
informatica Training in Bangalore
Blue Prism Training in Bangalore
MERN StackTraining in Bangalore
MEAN Stack Training in Bangalore
RPA Training in Bangalore
Qlikview Training in Bangalore
Android Training in Chennai
Android Course in Chennai
android development course in chennai
Android training
Android Training in Annanagar
Android training in vadapalani
Digital Marketing Course in Chennai
Python Training in Chennai
Big data training in chennai
JAVA Training in Chennai
Fashion Blogger in Surat
Surat Blogger
Indian Fashion Blogger
Fashion Blogger in India
Final Year Projects for CSE in Angular
Angular Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
digital marketing company in chennai
seo service in chennai
web designing company in chennai
social media marketing company in chennai
plant nursery in chennai
rental plants in chennai
corporate gardening service in chennai
Cosmetics Shop in Chennai
الرائد افضل شركات تنظيف خزانات المياه يسعدنا ان نقدم لكم افضل خدمات
شركة غسيل خزانات بالمدينة المنورة تنظيف خزانات بالمدينة المنورة
افضل شركة تنظيف منازل بالمدينة المنورة شركة تنظيف بيوت بالمدينة المنورة
AWS Training in Bangalore
AWS Training in Chennai
AWS Course in Bangalore
Best AWS Training in Bangalore
AWS Training Institutes in Bangalore
AWS Certification Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
PHP Training in Bangalore
DOT NET Training in Bangalore
Get inspired by your blog. Keep doing like this....
Ethical Hacking Course in Chennai
Ethical hacking course in bangalore
Ethical hacking course in coimbatore
Hacking course in bangalore
Ethical hacking in bangalore
Ethical hacking training in bangalore
Ethical Hacking institute in Bangalore
Ethical hacking Training institute in bangalore
Tally Course in Bangalore
German Classes in Bangalore
Python Training in Chennai
Python Training in Bangalore
Python Training in Coimbatore
Python course in bangalore
angular training in bangalore
Web Designing Course in bangalore
python training in hyderabad
Best Python Training in Bangalore
python training in marathahalli
Python Classes in Bangalore
Thanks for sharing such a nice info.I hope you will share more information like this. please keep on sharing!
internship in chennai
internship in chennai for cse
internship for mba in chennai
internship in chennai for hr
internship in chennai for mba
companies for internship in chennai
internship in chennai for ece
paid internship in chennai
internship in chennai for biotechnology
internship in chennai for b.com students
internship in chennai for electrical engineering students
one month internship in chennai
vlsi internship in chennai
unpaid internship in chennai
internship for hr in chennai
internship training chennai
internship for freshers in chennai
internship in chennai for it students with stipend
internship in accenture chennai
naukri internship in chennai
Jupyter Notebook
Jupyter Notebook Online
Jupyter Notebook Install
Automation Anywhere Tutorial
Rpa automation anywhere tutorial pdf
Automation anywhere Tutorial for beginners
Kivy Python
Kivy Tutorial
Kivy for Python
Kivy Installation on Windows
top 10 uses of python
jobs for ccna certified
scope of php in future
future scope of machine learning
data science interview questions and answers
HIV/AIDS Complete cure test result in Tamilnadu | Hiv aids treatment in bangalore
Best hiv doctor in india | Hiv positive treatment in india
Medicine for aids in india | HBSag complete cure for Herbal in india
vé máy bay đi Mỹ giá rẻ 2021
vé máy bay đà lạt hà nội hôm nay
vé máy bay vinh sài gòn giá rẻ
vé máy bay đà nẵng nha trang
chuyến bay về việt nam từ mỹ
thuê xe 29 chỗ đi sân bay nội bài
combo quy nhơn flc
Adidas showroom in madurai | Woodland showroom in madurai
Puma showroom in madurai | Crocs showroom in Madurai
mobile app development companies in chennai
mobile app development company in chennai
Angularjs Course in Chennai
Angular Online Training
Angular Course in Coimbatore