DEV Community

ogbotemi-2000
ogbotemi-2000

Posted on

4 3 2 1 2

A smart contract that accepts a URL and return a JSON of only used CSS styles

This is a submission for the Build Better on Stellar: Smart Contract Challenge : Build a dApp

What I Built

A smart contract on Stellar testnet that will receive a website URL and return a JSON of the used styles on the page as an improvement over this webapp I had deployed months ago:https://rmrf-css.vercel.app/

Demo

With a progressive UI, the user in onboarded on the useful aspects of the webapp as seen at the URL above.

The final logic flow that offers a customizable speed of execution
Image description

My Code

Reboot via Stellar blockchain

An experiment at trying HTTP requests for my first time in rust while communicating directly with the API layer of the webapp

use reqwest;

// tokio let's us use "async" on our main function
#[tokio::main]
async fn main() {
    // chaining .await will yield our query result
    let result = reqwest::get("https://rmrf-css.vercel.app?url=https://google.com").await;

    println!("{:?}", result)
}

Enter fullscreen mode Exit fullscreen mode

Journey

The algorithm to trim css files has a very good performance and rewriting it in Rust will offer unreal speeds.

Going further

The old algorithm for trimming, available at the provided URL has been rewritten first, in Javascript and eventually, it will be rewritten in Rust.

If the Javascript version of the rewritten algorithm can boast a speed of 1.5s for unminified TailwindCSS against over 600 unique classnames, its rust equivalent is expected to be in the range of 60ms and below.

The rewrite will be debuted on the webapp: https://rmrf-css.vercel.app for web enthusiasts to get a whiff of its faster execution.

Join in on the code here!
https://github.com/ogbotemi-2000/rmrf-css-client

Additional Prize Categories: Glorious Game and/or Super Sustainable

Neon image

Serverless Postgres in 300ms (❗️)

10 free databases with autoscaling, scale-to-zero, and read replicas. Start building without infrastructure headaches. No credit card needed.

Try for Free →

Top comments (0)

Image of Stellar post

🚀 Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

If you found this post useful, please drop a ❤️ or leave a kind comment!

Okay