2
2 Comments

Downgrade About Dark Mode And Content Security Policy

https://observatory.mozilla.org/

https://observatory.mozilla.org/

Observatory (grade checker by Mozilla) will downgrade score if website still use inline <style> or <script>.

https://infosec.mozilla.org/guidelines/web_security#content-security-policy

How to fix this issue while dark mode toggle needs "onclick" to trigger and switch the light / dark mode?

submitted this linkon September 22, 2019
  1. 2

    If I am reading it correctly you can use onclick event unless you implement it in an actual javascript file and bring it to the site with a <script src=“”> reference instead of inline adding it to the html element.
    CSP just wants to make sure to control what is loaded from where. inlining code goea against that hence the downgrade.

    1. 1

      I moved the inline code to separate file. And it works. Thanks.