uncss: Root-relative URLs do not work for JS files
Root-relative URLs for JS files cause errors like this: Error: Could not load script: "file:///test.js"/
Originally posted in https://github.com/giakki/uncss/pull/280#issuecomment-281437450, because I thought the issue was specific to the JSDom implementation. @RyanZim informed me, though, that the same error occurs with PhantomJS, it is just quietly ignored.
@vseventer suggested:
uncss allows /css/main.css, so there is no reason why /js/main.js shouldn’t be supported also. This could be fixed by having htmlroot (or, more precise, utility.parsePath) apply to stylesheets and scripts (currently, it only applies to stylesheets).
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (16 by maintainers)
Ok, I found it! Stupid mistake…
It needs to be an array.
I think this issue is no longer valid, yeah. Root-relative files work fine with
htmlroot.Ok thanks. Can you provide a self-contained repro case? Or can you log and share the values I requested above? Namely, what is the
cssobject being passed intogetUsedSelectors?I agree with @vseventer.
I don’t know if/how this is possible via PhantomJS, however, in jsdom, this could be done via
I will submit a patch to the jsdom branch when I get a chance (unless someone gets there before me). When it is merged to the jsdom branch, I will publish a new version of
uncss-jsdom.