question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assuming as equal two classes differentiated by a number at the end

See original GitHub issue

I have the following code:

var purify = require('purify-css');
var content = '<div class="hello">sad<//div><div class="hello2">asdasda<//div>';
var css = '.hello { color: green; } .hello3 { display: block; }';

  var options = {
      output: 'purified.css',

  // Will minify CSS code in addition to purify.
  minify: true,

  // Logs out removed selectors.
  rejected: true,
  info: true
};

purify(content, css, options);

And then the content of purified.css is: ‘.hello { color: green; } .hello3 { display: block; }’

It is not deleting hello3, but if I change css as follows, then it works: var css = '.hello { color: green; } .h { display: block; }'; And then the content of purified.css is: ‘.hello { color: green; }’ I guess it is not taking into account the number at the end of the class.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

9reactions
adamwathancommented, Aug 1, 2017

Solving this would be a huge win; I have tons of utility classes ending in numbers or containing non-standard characters like :, for example:

.md\:mb-5

…used like:

<div class="md:mb-5">...</div>

…which adds a bottom margin of my 5th spacing unit on medium screens and larger.

Currently, after running PurifyCSS, Chrome still reports 97% of my CSS as being unused:

image

2reactions
adamwathancommented, Aug 14, 2018

Uncss wouldn’t work for me because it can’t be run against arbitrary template languages like PHP even. It seems it tries to be a bit too smart IMO, by actually running client side JS and parsing the DOM to find classes, etc.

Purgecss is by design very “dumb”, it just iterates over all of your CSS classes and looks for them as simple string matches in any source file you provide, like a template or JS file. It doesn’t actually parse HTML or anything, it literally just runs a regex against the files you provide. In my experience that makes it very very predictable and easy to use because it’s obvious how to author your templates in a “purgeable” way because the mental model is so straightforward. On Tue, Aug 14, 2018 at 5:57 PM Jay Holtslander notifications@github.com wrote:

@adamwathan https://github.com/adamwathan Yeah was looking at both purgecss https://www.purgecss.com/ and uncss https://github.com/uncss/uncss. Do you have any feelings on uncss vs purgecss?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/purifycss/purifycss/issues/147#issuecomment-413029562, or mute the thread https://github.com/notifications/unsubscribe-auth/AEH3bKgtFyMV1ovTPWP1oOXcYDn12OKqks5uQ0fYgaJpZM4MfAge .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implicit differentiation review (article) - Khan Academy
In implicit differentiation, we differentiate each side of an equation with two variables (usually x x xx and y y yy) by treating...
Read more >
Best way to compare two complex objects - Stack Overflow
Should two objects with the same PersonId but different Age values be considered equal or different? The answer above assumes that one is...
Read more >
Chapter 5 Flashcards - Quizlet
Explanation: Overloaded methods are two methods in the same class that have the same identifier, but a different number, type or order of...
Read more >
Page 7: Differentiate Product - IRIS Center
When teachers differentiate product, they assess the same concept or skill for each student at the end of a unit of study; however,...
Read more >
Differentiation Strategies and Examples: Grades K-2 - TN.gov
example, students write two numbers between 1 and 10, circle the number that is ... together (in groups or as a whole class)...
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found