Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
gulp-ng-html2js
Advanced tools
A Gulp plugin which generates Javascript code which loads the HTML files of your AngularJS app into the $templateCache.
A plugin for gulp which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doens't need to request the actual HTML files anymore.
First, install gulp-ng-html2js
as a development dependency:
npm install --save-dev gulp-ng-html2js
Then, add it to your gulpfile.js
:
var ngHtml2Js = require("gulp-ng-html2js");
gulp.src("./partials/*.html")
.pipe(ngHtml2Js({
moduleName: "MyAwesomePartials",
prefix: "/partials"
}))
.pipe(gulp.dest("./dist/partials"));
The main reason to use this module would be optimization. By pre-loading the HTML files, you can spare requests and
loading time when the files are actually needed. When you are optimizing, you should do it properly. So, we should add
the following plugins: gulp-minify-html
, gulp-uglify
, and gulp-concat
:
var ngHtml2Js = require("gulp-ng-html2js");
var minifyHtml = require("gulp-minify-html");
var concat = require("gulp-concat");
var uglify = require("gulp-uglify");
gulp.src("./partials/*.html")
.pipe(minifyHtml())
.pipe(ngHtml2Js({
moduleName: "MyAwesomePartials",
prefix: "/partials"
}))
.pipe(concat("partials.min.js"))
.pipe(uglify())
.pipe(gulp.dest("./dist/partials"));
This way you end up with 1 single, minified Javascript file, which pre-loads all the (minified) HTML templates.
Type: String
The name of the generated AngularJS module. Uses the file url if omitted.
Type: String
The prefix which should be prepended to the file path to generate the file url.
Type: String
The prefix which should be subtracted from the file path to generate the file url.
FAQs
A Gulp plugin which generates AngularJS modules, which pre-load your HTML code into the $templateCache. This way AngularJS doesn't need to request the actual HTML files anymore.
The npm package gulp-ng-html2js receives a total of 4,116 weekly downloads. As such, gulp-ng-html2js popularity was classified as popular.
We found that gulp-ng-html2js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.