juice
astro
juice | astro | |
---|---|---|
3 | 505 | |
3,057 | 42,342 | |
0.7% | 4.9% | |
5.9 | 10.0 | |
5 months ago | 6 days ago | |
JavaScript | TypeScript | |
MIT License | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
juice
-
How to Improve Your Emails With CSS?
Another tool worth mentioning is the Responsive Email CSS Inliner by HTML Email. Just like other conversion tools, this inliner works similarly by reading your embedded CSS in one window and making it inline in another. The feature that makes it stand out from the rest is that it also has a third window that demonstrates what the actual email would look like, both on mobile and desktop. Additionally, there is an option to download a .html file of the email. Since the tool is powered by Juice, an open-source project, it can also be easily integrated into your Node.js projects and works in client JavaScript.
-
Announcing Vituum - Template engines and more in Vite
Juice
-
In-lining Styles Client Side
And it in-lines tagged HTML wonderfully. Works well.
Still, it's overkill, brings with it dependencies cheerio, mensch and slick and a look into the code behind the on-line demo makes rapidly clear that Juice is parsing the style sheets and applying them in what looks to be, must be, a product of its age. It has over 1500 lines of Javascript and the repo was created in 2011 - the state of Javascript was woeful then compared with today (though not as woeful as in 2001 π).
So we have to give Juice full credit and admiration for its age and endurance, and that it's still being maintained and is useful. But I'll respectfully pass it by as I'm looking for a minimalist, native Javascript solution as far as possible, using the state of Javascript in 2021 a whole decade later (which in IT terms is an eon).
inline-css π
Immediately disconcerting is the npm documentation for this package. It says simply "Inspired by juice" and fails to tell us why the authors felt that embarking on a new project was worth their while. It hints at the fact that it's better than Juice in some way or other (why else start a new project inspired by it?), but lays no claim as to if or how that might be the case. A dark horse.
The github repo dates to 2015 and so, it's not as long-in-the-tooth as Juice, but still, it likely leans on a more meager JavaScript standard than we have available today and quite possibly, like Juice resorts to parsing CSS code and interpreting it. It has about 1700 lines of Javascript and so is even larger than Juice! The last code contributions on github are early 2020 so at least it's being maintained which is good.
Still, it also depends on cheerio, and so falls a little short of a native solution but worse, it does not provide us with any suggestion as to run-context (server side or client side).
It's on npm, which is Node.js which suggests server-side JavaScript. It doesn't rule out that it works client-side, but there is zero indication provided that it does nor a test site, the way Juice provided. And like it or not, I associate npm primarily with Node.js and server side applications (rightly or wrongly).
So for my needs, it goes respectfully into the too-hard basket. Failed, in a sense, by the poor quality of its own introductory presentation. An irony, because there is some nice documentation there, just not a nice introduction that spells out whether it runs client-side or not, how to if so, and how it's different from Juice and why we'd use it. All the obvious questions I have surfing in on it.
css-inliner π
Long story short, the introductory documentation fails this package even more than that for inline-css did. Again, it's on npm, and so looks targeted at server-side use and makes no effort to mention the other two (Juice or inline-css), or differentiate itself from them. The github repo dates back to 2015 as well and so it looks at some level to be an example of modern parallel development, this and inline-css emerging at the same time. And unsurprisingly, it again has around 1600 lines of JavaScript. The last code contribution was 2020 so again, at least it's being maintained which is good I guess.
Still, no hint as to the run-context it supports (server-side and/or client-side) but hints, via its npm references and templating languages that it's a server-side tool not a client-side tool. Which doesn't rule out client-side application but again no claim that it works in that context, and no tips on how (if it does) and no demo site, so it's a respectful pass. Still seeking a lean native Javascript solution in preference to some pet project lacking clarity and exhibiting bloat.
Native Javascript π
The failure to find an existing solution, leads me to (seeking) a native JavaScript implementation and the journey of discovery that lies behind that.
document.styleSheets
provides us with a collection ofCSSStyleSheets
andCSSStyleSheet.rules
in turn provides all of theCSSStyleRules
in use andElement.matches()
tells us ifCSSStyleRule.selectorText
applies to a given element.window.getComputedStyle()
provides rapid access to the complete set of computed styles. That is, crucially it has taken all those styles that position things relative to the browser window and calculated where, in real coordinates it landed. Among other things. Crucially, it also has resolved all of CSS variables. It describes what an element actually looks like on the screen, rather than in the abstract CSS.We can use the style sheets and the computed styles to update the style attribute of each element and then, when all is done the
innerText
and theinnerHTML
orouterHTML
are available for the thetext/plain
andtext/html
MIME parts respectively.Given we're in-lining styles, and we don't want to actually change the element in the DOM (we're just aiming to copy it to the clipboard in one form or another), we have to take a copy of the DOM element and in-line the styles on that. We have to use the computed style from the source element however as it is rendered on screen and the copy is not (hence has not got computed styles). To wit, we will have a source and target element one that is in the DOM and provides computed styles, and one that is not in the DOM and receives in-lined style attributes.
Importantly an implementation like this is maybe 200, or 300 lines of JavaScript and not 1500.
That more or less covers us and we have a terse native JavaScript in-lining solution!
But ... performance, performance ... turns out that it's not slow, but it's not fast either, let's take a look at performance next, before we dive into an actual code implementation of the above schema - next week's article.
astro
-
Composable architecture example: Go headless (best practices)
Astro
-
Building static websites
Case study 4: Astro
-
Setting up Doom Emacs for Astro Development
Astro is the new hot new web framework on the block. All the cool kids are using it. I've recently given up, drank the Kool-Aid, and gone all in on it.
-
Building a self-creating website with Supabase and AI
Built with Supabase, Astro, Unreal Speech, Stable Diffusion, Replicate, Metropolitan Museum of Art
-
The Subtle Case For and Against React
Astro to use every framework at once instead of just react? https://astro.build/
-
Run a Linux Distro in your Android device
Depending on the stack of the repository you are cloning, you might have to install additional dependencies. For this demo, I'm using my own website, which is a static website built with Astro.js. It which requires to have Node.js installed and Yarn for package manager.
-
Ask HN: Freelance website builders/maintainers, what's in your 2024 toolkit?
Database: turso [7] or neon postgres [8] with (drizzle orm) or cloudflare durable objects
1. https://github.com/withastro/astro
-
Ask HN: What's the simplest static website generator?
Maybe a bit too elaborate for your taste, but I've used https://astro.build/ and loved every bit of it.
-
How to Integrate Astro With ApostropheCMS pt. 1
Astro is an open-source JavaScript framework known for its versatility, performance, and new approach to web development. It enables developers to create fast, modern, content-rich web applications and sites using the "Bring Your Own Framework" (BYOF) model.
-
Growing a side-project to 100k Unique Visitors in one week
Astro was always on my list of things to learn. I've been using Remix and NextJS for a while, and I was interested in trying out a new framework. I decided it would be a good opportunity to build the site with it. This decision turned out to be a great one, as it saved me a lot of money on hosting costs later on.
What are some alternatives?
email-templates - Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
qwik - Instant-loading web apps, without effort
css-inliner - A simple and modern CSS inliner. Optionally supports CSS preprocessors (e.g. Less) and templating languages (e.g. Handlebars).
vite - Next generation frontend tooling. It's fast!
cheerio - The fast, flexible, and elegant library for parsing and manipulating HTML and XML.
eleventy πβ‘οΈ - A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
arrayfire-rust - Rust wrapper for ArrayFire
Hugo - The worldβs fastest framework for building websites.
inline-css - Inline css into an html file.
SvelteKit - web development, streamlined
wgpu - Cross-platform, safe, pure-rust graphics api.
fresh - The next-gen web framework.