Package: pyramid_html_minifier
pyramid_html_minifierintroducessafehtml minification
withno overheadforPylons/Pyramidapplications powered by:Chameleontemplates (ZPTbased template implementation).Chameleontemplates are still validXML, so they can be safely minified with not
too aggressive minification optionsWhat you get with pyramid_html_minifierbandwith and performance.Save precious kilobytes (~50-80% depending on your templates).
It is quite important for bandwith usage and improved performance,
even more important if you have to manage a big and fatPylons/Pyramidbased website with a lot of traffic.
Seehttps://www.npmjs.com/package/html-minifierno overhead.The minification is based on a build step (a sort of
gulp/grunt based collectstatic). So no minification on the flysafe template/html minification. It works even withmacrosandslots.
This pattern has been adopted on production websites with no issues
after 1 year. So I dare say it is a safe pattern after a
1-year quarantine without any sort of problems. You should only
remember to disable too aggressive minification options (see next
sections)What pyramid_html_minifier doesWhatpyramid_html_minifierintroduces:a custom.htmlrenderer (interpreted asChameleontemplates)support fordistvsapp, commonly used inYeomanprojects.appwill be used for development, whiledistin production mode (based on a template minification build).This way you can start developing static mock applications (even
heavily Javascript based) using theYeomanworkflow and use your
modified html files enriched by macros and slots asChameleontemplates.How to use pyramid_html_minifierHere you can see how to enable Chameleon templates minification in yourPylons/Pyramidweb application:put yourChameleontemplate file intemplates/app/master.htmland its
minified version intemplates/dist/master.html(the.htmlextension is
important). Obviously don’t do minification by hand, addYeomanin your
development workflow with its related tools for automation.
This package does not provide anygulporgruntconfiguration,
you are supposed to create your own setupregister a normalPylons/Pyramidcallable view withrenderer="your_plugin:templates/{0}/master.html". The{0}is only
a placeholder thatpyramid_html_minifierwill fill depending on your
settings. See next steptellpyramid_html_minifierif you want to pick up standard templates or
minified ones adding thepyramid_html_minifier.placeholdersetting to your.inifile. Typical value for development isapp(the default one),
whiledistis usually used for prodcution environments.
Example:pyramid_html_minifier.placeholder = distaddpyramid_html_minifierto your pyramid.includes settingThe final .ini file should looks like the following one:pyramid.includes =
    ...
    pyramid_html_minifier

...

pyramid_html_minifier.placeholder = distSafe minification optionsI suggest to automate the build process integrating theYeomanworkflow into yourPylons/Pyramidproject for the best developing experience.I suggest to use thehtml-minifierminificator and its friendgulp-html-minifierdisabling too aggressive html minification options.In particular be sure that thekeepClosingSlashoption is enabled andremoveAttributeQuotesis disabled.Here you can see a real example working configuration:const htmlMinifierOptions = {
  collapseBooleanAttributes: true,
  collapseWhitespace: true,
  removeComments: true,
  removeCommentsFromCDATA: true,
  removeEmptyAttributes: true,
  removeRedundantAttributes: true,
  useShortDoctype: true,
  keepClosingSlash: true,
  }

...

gulp.task('html', ['styles'], () => {
  const assets = $.useref.assets({searchPath: ['.tmp', 'app', '.']});

  return gulp.src('app/*.html')
    ..
    .pipe($.if('*.html', $.htmlMinifier(htmlMinifierOptions)))
    ...
    .pipe(gulp.dest('dist'));Why YeomanWhyYeoman:better and more modern web development experienceminification and/or resources concatenation (images, css, Javascript)more. Seehttp://yeoman.io/LinksHere you can find a project usingpyramid_html_minifier:https://github.com/Kotti/kotti_frontendMore details about case studies using the same pattern:http://davidemoro.blogspot.it/2014/09/plone-angularjs-yeoman-starter.htmlhttp://davidemoro.blogspot.com/2014/09/pyramid-starter-seed-yeomam-part-1.htmlhttp://davidemoro.blogspot.it/2013/08/yeoman-express-and-angularjs.htmlAuthorsDavide Moro (https://twitter.com/davidemoro)0.1 (2015-08-03)Initial version