Skip to content

Rule: Don't insert static CSS into the DOM #57

@joethei

Description

@joethei

A common snippet I see in the plugin onload is something like this:

const styleSheet = document.createElement('link');
styleSheet.rel = 'stylesheet';
styleSheet.href = this.app.vault.adapter.getResourcePath(`${this.manifest.dir}/styles.css`);
document.head.appendChild(styleSheet);

Which makes no sense, since Obsidian already handles that, so it's probably generated by an LLM.

Or also, most often found in modals:

const style = document.createElement('style');
style.textContent = `Some CSS here`;
document.head.appendChild(style);

Both of these usually also have no cleanup function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions