Giter VIP home page Giter VIP logo

Comments (5)

tomayac avatar tomayac commented on May 20, 2024

Thanks for opening the issue. The problem you're describing was already discussed before, I have provided an answer in #20 (comment). Hope this helps. I'm closing the issue, but feel free to comment again. Cheers!

from dark-mode-toggle.

francislavoie avatar francislavoie commented on May 20, 2024

Ah thanks, I searched for the wrong words πŸ‘

You said:

So long story short, there’s no way to prevent this, but you can limit the negative effect by making sure the toggle code executes as soon as possible during the loading phase of your page. Hope this helps somewhat.

It seems to me like the toggle code doesn't run until <dark-mode-toggle> is encountered (I'm making this assumption because if the JS is in the <head> but the toggle element is not rendered, nothing happens). I put <script type="module" src="https://unpkg.com/dark-mode-toggle"></script> as early as possible in the <head> but it still happens. Is there anything else I could do to make it load earlier?

from dark-mode-toggle.

tomayac avatar tomayac commented on May 20, 2024

You could preload the module:

<link rel="modulepreload" src="https://unpkg.com/dark-mode-toggle" crossorigin>

from dark-mode-toggle.

francislavoie avatar francislavoie commented on May 20, 2024

Hmm, looks like that's still experimental https://caniuse.com/#feat=link-rel-modulepreload

from dark-mode-toggle.

tomayac avatar tomayac commented on May 20, 2024

It is experimental. But where it works, it helps. And where it doesn't work, it doesn't cause harm.

from dark-mode-toggle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.