• Hi Erik,

    I just tried your plugin. Great! Thanks for making it available. Installing was easy, and adding the code block, too. However I have one issue: Each page loads in light mode first, then switches to dark in the fraction of a second. Those flashes don’t look nice.

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Erik

    (@codekraft)

    Ciao @soundfix, can you please try to exclude the “dark-mode.js” script from defer? is a small script but must be executed immediately 😀

    Thread Starter soundflix

    (@soundflix)

    Where or how do I “exclude the “dark-mode.js” script from defer”?

    Plugin Author Erik

    (@codekraft)

    probably it’s related to a caching plugin like LiteSpeed Cache, is something I see also applied to all the other scripts on your site.

    Thread Starter soundflix

    (@soundflix)

    I don’t have LiteSpeed Cache or other caching I know of.

    Plugin Author Erik

    (@codekraft)

    Sorry, the defer seems related to WordPress 6.4

    I have to fix this issue releasing a new version of the plugin… Expect a new version soon

    Thread Starter soundflix

    (@soundflix)

    Ok, I’ll wait for the fix!

    Meanwhile I tried to exclude defer with a filter in functions.php like this, but it didn’t work.

    Plugin Author Erik

    (@codekraft)

    Plugin Author Erik

    (@codekraft)

    if you feel confortable with editing the code of the plugin and you want to give a try with the new enqueue code:
    – Remove from block.json the viewscript (at the end)
    – Add at the end of dark-mode-block.php (the main php file of this plugin)

    /** Enqueue the block assets */
    \add_action( 'wp_enqueue_scripts', function () {
    	\wp_enqueue_script( 'dark-mode-block', plugin_dir_url( __FILE__ ) . '/build/dark-mode.js', array(), '0.1.0', array( 'strategy' => null, 'in_footer' => false, ) );
    }, 0 );

    Otherwise, don’t worry and I will try to release a new version asap shortly

    Thread Starter soundflix

    (@soundflix)

    Remove this whole line?

    "viewScript": "file:./build/dark-mode.js",
    Plugin Author Erik

    (@codekraft)

    yes, block.json doesn’t allow any options for enqueues. The 2nd change (the edit in the php file) will enqueue that script in right way for this plugin.

    Plugin Author Erik

    (@codekraft)

    Since the changes were really limited I published the update immediately, Let me know if it works OK for you now!

    Thread Starter soundflix

    (@soundflix)

    Pure, dark gold! 100%

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Dark Mode comes in with delay’ is closed to new replies.