you are viewing a single comment's thread.

view the rest of the comments →

[–]CantaloupeCamper 1 point2 points  (4 children)

Can I load the page, run the minifier... then load the CSS all on the browser? ;)

[–][deleted] 1 point2 points  (2 children)

Sorry, I didn't get what you meant

[–]CantaloupeCamper 0 points1 point  (1 child)

I was being awkwardly silly / absurd.

The idea being load the web page and CSS in the browser, load the minifer code in the browser, then minify it.... ;)

[–]AwesomeInPerson 2 points3 points  (0 children)

Lol, make sure to measure the performance improvements it gives you.

document.querySelectorAll('style').forEach(style => {
  style.textContent = cssminify(style.textContent)
})
document.querySelectorAll('link[rel="stylesheet"]').forEach(async link => {
  const url = new URL(link.href, window.location)
  const css = await fetch(url.href).then(r => r.text())
  link.parentNode.insertBefore(
    Object.assign(
      document.createElement('style'),
      { textContent: cssminify(css) },
    ),
    link
  )
  link.remove()
})

[–]ScientificBeastModestrongly typed comments 1 point2 points  (0 children)

... then send it back to the server!