314chan
/314/ - Site Discussion
Discuss 314chan, it's policies etc. textboard for now,
Catalog

Posting mode: Reply
E-mail
Subject
Comment
Dont.
Password (Password used for deletion)
  • Currently 21 unique user posts.
  • Read the Rules and FAQ before posting.
  • (Requires Javascript)

We have added ads, parley needs to recoup costs from the past few months. Please click around, and if you want to advertise on 314chan, there should be a button on a-ads's website! (Click the mustache in the top right of the current ad if you're interested!)


314chan site bounty system thread



Wanna make money for making features for 314chan?


enlist in team314chan's feature bounty program!

Current list:

  1. $20 - Fix thread updating; if thread's json file is updated, create new post view, and fill contents.
  2. $5 - Ensure "Nighty Time" (Night mode) CSS loads first if Option is enabled, so it doesn't flash a bright color, then set the correct CSS
  3. thanks anon for the fix. 'preciate ya!
>>
>>21
For 2, its probably because the theme loading is inside an event like document.ready or document.on('domContentLoaded'). If night time mode just loads a second css file, you should add it in the head without waiting for domcontent loaded, so it adds the css file after the "base" css file immediately (i.e. before the body loads). No need to pay. Should be a pretty simple fix, unless I am mistaken :)
>>
>>22
UPDATE: so after trying to implement this on my own site, I can confirm: impossible without an ugly hack
since dynamically adding a link tag or changing the href of an existing one will load the new cs file asynchronously, no matter what you do it will always be prone to flashing.

The best you can do is a synchronous ajax request to download the css, then setting it in a style attribute. That's the only way I can think that will actually block until the dark theme css is inserted. I seriously don't recommend that.
>>
>>23
Unlucky, so the dom paints before JavaScript loads? That's a little crazy.
>>
>>23
This works but the ajax will cause slightly slower page load.
>>24
There is a better way.

>>24
Since the link is inserted dynamically, the browser does not wait for its href or src tag to fully load before painting DOM.

But you can employ strategy similar to >>23
You add a link tag dynically when they enable darkmode, and store the css text itself in localstorage. then on subsequent pageviews, insert it as an inline style tag with the css from localstorage. And then insert a link element into the head dynamically AFTER that and update the css in localstorage each time to prevent caching issues. As long as you keep localstorage under 10MB (css is mich smaller than that) its not a bad solution imo
>>
>>24
Solution: https://pastebin.com/QYnbsawh
Its a modified part of https://www.314chan.org/js/common.js
Look for the line "if (localStorage.getItem('o_night_css') == 1) {" and remove that if statement, then put the code in the pastebin right after the first if statement in that whole script "if (localStorage.getItem("firsttime") != 1)" so it comes before "$(document).ready(function () {"
>>
>>24 >>26
Hey, I noticed you changed the javascript and it works great now :) No more flash of light theme, goes straight to dark.
>>
test
>>
'''test'''
''test''
==test==
>>
>>34
read the FAQ/Post Formatting before posting
https://www.314chan.co/formatting.html

Delete post [File Only] Password
Reason


- Haruko + mitsuba -

  In memory of 314chan's co-founder, goo.