Prefixing a CSS File: A Guide

The element selector proved to be challenging, indicating room for improvement. To address possible duplicates, you can consider using Solution 2: utilizing SCSS to automatically prefix your classes. Simply create a file called mystyle.scss and run a command in your terminal to implement this feature. By doing so, all of your CSS will have a prefix. You can learn more about node-sass on their website. Additionally, this method condenses the entire CSS into a single line, removes all comments, and checks the existence of a specific element before imploding it. Lastly, it’s worth mentioning that JohnyFree deserves more recognition for his contributions.


Solution:

The link tag used for linking the CSS is similar to any other element.

set the href like this


var css = $("#css").attr("href");
var href = css.replace(".css",css+prefix);
$("#css").attr("href",href);

Frequently Asked Questions