Comments (11)
Is [
:host([hidden]) {…}
] necessary?
Yes, it's a best practice.
from dark-mode-toggle.
You don't just want minify-template-strings (i.e. just removing whitespace), you want minify-css-in-template-strings. I don't know of an existing tool that does this.
Eagerly awaiting CSS modules that will make this so much better.
from dark-mode-toggle.
You don't just want minify-template-strings (i.e. just removing whitespace), you want minify-css-in-template-strings. I don't know of an existing tool that does this.
Some other ideas to reduce minified bundle size: #11
from dark-mode-toggle.
Is this necessary?
:host([hidden]) {
display: none;
}
I thought this was the default but am likely missing something.
from dark-mode-toggle.
Another thing that jumps out is this.
occurs more than 150 times in the minified source. We could largely reduce that number by doing something like const _this = this;
at the top of the constructor
. _this
can then be minified just like any other identifier.
Although this likely wouldn't reduce the gzip/brotli size, it would reduce the number of bytes that need to be parsed and compiled.
from dark-mode-toggle.
You don't just want minify-template-strings (i.e. just removing whitespace), you want minify-css-in-template-strings. I don't know of an existing tool that does this.
Eagerly awaiting CSS modules that will make this so much better.
We could hack something together ourselves. The template literal's contents would be stored in a separate source file in the repository, and processed by a custom script that strips whitespace and applies some simple CSS optimizations. The result would then be injected as a template literal into the built .js
file. The downside is that the source *.js
file would no longer be useful for testing; you'd have to create a build just to get a working file. It's definitely a trade-off... Maybe it's worth it though.
Happy to prototype this if this doesn't sound too horrible to you.
from dark-mode-toggle.
We could hack something together ourselves.
Sure, but at this point you'd build a build system. I really preferred if we instead chimed in on making CSS Modules a thing rather sooner than later. If you could review their proposal and comment on it, this would be a better use of your brain in my opinion.
from dark-mode-toggle.
We could largely reduce that number by doing something like
const _this = this;
at the top of the constructor._this
can then be minified just like any other identifier.
Great idea, thanks. Could you add this to your PR? You can test the changes by running npm run start
and navigating to http://localhost:8080/demo (you have probably figured this out, but just thought I'd point it out). Will add this to the README as well.
from dark-mode-toggle.
Great idea, thanks. Could you add this to your PR?
Tried it, but turns out not to save anything: #11 (comment) So didn't add it to the PR.
Thanks for the pointer, I have been testing the changes!
from dark-mode-toggle.
Also added the instructions to the README.
from dark-mode-toggle.
Closed via #11. 🎉
from dark-mode-toggle.
Related Issues (20)
- [Feature Request] Set SVG icons HOT 1
- Unable to Load png files when running on Github Pages HOT 2
- Apart from `light` and `dark`, add a `system` option HOT 9
- Add aria-label for lighthouse HOT 5
- Dead GitHub Pages HOT 1
- Any way to toggle light/dark native widgets when using <meta name='color-scheme' content='light dark'> ? HOT 3
- dark-mode-toggle with React HOT 10
- Dark mode website HOT 5
- "Permanent" property seems to have stopped working HOT 5
- Implement saving light/dark mode HOT 8
- Dark mode doesn't work HOT 5
- Keep light mode after changing page for Wordpress Theme HOT 3
- Accessibility error HOT 2
- Consider aria-label="auto" aria-live="polite" HOT 1
- Reloading in the demo in dark mode still causes an initial flash of the light theme. HOT 8
- Problems styling ::parts and pseudo elements such as ::before HOT 15
- [feature request] support SRI (sub resources integrity) HOT 6
- [feature request] support Bootstrap 5.3 color modes HOT 3
- Support for using as a React component HOT 2
- Add support for declarative shadow DOM
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dark-mode-toggle.