Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created September 2, 2017 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netsi1964/00deb99703e8bef8b750176d7e009de7 to your computer and use it in GitHub Desktop.
Save netsi1964/00deb99703e8bef8b750176d7e009de7 to your computer and use it in GitHub Desktop.
console snippet: how much in the HTML could be saved if removing HTML comments and newlines?
var source = document.documentElement.innerHTML;
var original = source.length
var saved = (original-(source.replace(/<!--.*?-->/g,'').replace(/\n/g,'').length));
console.log("This page could be reduced by "+saved+" bytes, which is around "+Math.round(saved/original*100)+"%")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment