Giter VIP home page Giter VIP logo

Comments (13)

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024 1

By removing that part from the footer, site generation goes from 48 => 24 seconds. Files also get half the size.

from hugo-theme-docdock.

Pilskalns avatar Pilskalns commented on June 9, 2024

I see Hugo has wonderful builtin function which could be as wide improvement to minify rendered HTML across all themes. No external build tools then required.

https://gohugo.io/templates/introduction/#whitespace

from hugo-theme-docdock.

Pilskalns avatar Pilskalns commented on June 9, 2024

@GeertvanHorrik can you try this e371ac0?

from hugo-theme-docdock.

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024

Doesn't seem to work. It's the spaces in front of the code that are the culprit:

image

from hugo-theme-docdock.

Pilskalns avatar Pilskalns commented on June 9, 2024

Yes, those spaces I "compressed". I did changes only inside <div id="navigation">..</div>. So many spaces should come from one of loops (range).

  1. You sure my commit is in effect for local copy you try?
  2. Maybe you have this file override outside theme directory?
  3. Restart Hugo, live-preview can fail update template files (if you use live-preview).
  4. Look for errors when starting local Hugo server.
    and...
  5. Can you locate from where exactly in .html layout those extra whitespaces come from?

from hugo-theme-docdock.

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024

Using this seems to fix it:

<div id="navigation">
<!-- Next prev page -->
{{with ($.Scratch.Get "prevPage")}}<a class="nav nav-prev" href="{{.URL}}" title="{{.Title}}"> <i class="fa fa-chevron-left"></i></a>{{end}}
{{with ($.Scratch.Get "nextPage")}}<a class="nav nav-next" href="{{.URL}}" title="{{.Title}}" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>{{end}}
</div>

from hugo-theme-docdock.

Pilskalns avatar Pilskalns commented on June 9, 2024

@GeertvanHorrik please check-out this compress-html-whitespace and check result

from hugo-theme-docdock.

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024

I think it's the spaces in front of the template codes that are the issue. Your fixes don't seem to fully solve the issue:

image

from hugo-theme-docdock.

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024

After some more tests, it already looks a lot cleaner and files have gone from 700kb => 360kb.

image

from hugo-theme-docdock.

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024

As a final experiment, I've opened the menu.html partial in notepad++, select all, shift + tab until there is no more indentation. Now the file is 320kb, which is a lot better.

from hugo-theme-docdock.

Pilskalns avatar Pilskalns commented on June 9, 2024

Those blank lines in #61 (comment) are from template lines, which has Hugo template code, but does not produce any actual output.

Removing whitespace before <a> tag would only remove from that line. It can't produce that amount of blank lines, and also have different indentation. Here all lines <li>, <a ... and </li> have same indent space.

Removing all, all, all odd spaces (minifying it) in template is not practical as it makes code and HTML hard to read. To do that for production level use tools for this purpose. I.e. something automated like Grunt or even SaaS like Netlify.

from hugo-theme-docdock.

Pilskalns avatar Pilskalns commented on June 9, 2024

@GeertvanHorrik I suggest this to be closed.

from hugo-theme-docdock.

GeertvanHorrik avatar GeertvanHorrik commented on June 9, 2024

Fully agree, thanks for fixing!

from hugo-theme-docdock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.