Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 21, 2021 04:28 pm GMT

ZERO CSS and just a single image to build a fully interactive SPA???!!?? Abusing the internet once more! [Extreme SSR!]

I am back at it again, abusing the internet and this one should really blow you away.

"hold onto your butts" from Jurassic Park 1

This time I really do think I have outdone myself.

I present to you:

A 3 page SPA with an interactive poll and a contact form, with no CSS and one DOM element - just a single image! (go on, inspect the page!)

I call it "Extreme Server Side Rendering (SSR)"

PLEASE NOTE: - if using a mobile you cannot use the contact form, I couldn't find a way of opening the keyboard without an <input> I am afraid! Try it on PC instead!

FINAL THING: Due to the round-trip time to the server the page feels "laggy", if you are on a 3G connection it might be unusable so wait until you are on a better connection before trying it!

> > > > Try the single image SPA here! (best viewed on PC) < < < <

What can I do in the SPA?

There are some fun bits for you to try:

It kind of works with a keyboard

Well, you can Tab to elements to highlight them. You can even activate them with "Enter".

Just don't expect a smooth experience (and I have only tested it in Chrome so it may not work in other browsers!)

The home page is responsive

Yup, if you try it on your mobile the home page actually has two different versions, a mobile one and a desktop one.

On mobile you can even open and close the menu!

I sadly didn't have time to make the other two pages responsive (this silly project took ages already!).

The poll actually works!

Cast your vote on the SPA as to what you think of my silly experiments!

The current results are as follows:

This has to be the stupidest thing I have ever seen - I love it!
60%

Quite silly, being rick rolled by ASCII text was sillier though!
16%

This is silly? I thought this was what server side rendering was!
23%

The contact form "works"

It is one of if not the worst experiences you will ever have on the web, but it works!

In fact you can see the messages people have posted via the SPA in the final section!

What is actually going on here?

Oh loads!

Essentially every interaction with the page is being tracked with JavaScript and cookies.

I am then sending that to a script on my server that renders an image based on mouse position, current focused item, keys pressed and more. I then send the constructed image back so you can view it!

Needless to say I now have a much greater appreciation for browser developers as there are so many little things that I just take for granted!

To give you an idea of how difficult this is, from the X and Y coordinates of the mouse I calculate if an item is hovered. To do that I need the X, Y, width and Height of each item on the page. I also need to know what state to turn that button to.

Now if you click, I have to check if the click is within the bounds of a button and what action should be performed!

Multiply that by 3 pages worth of buttons and inputs and a few other features and there is an awful lot I had to plumb together!

Final words before the comments

As with all of my silly experiments, there is no real point to this, just a bit of fun for you on a Friday!

Have a fantastic weekend!

User comments submitted via the contact page (may be disabled if people cannot behave )

Here are a few comments that people have added via the single image SPA!

InHuOfficial - 17:11 21/05/2021
I look forward to seeing the messages you all post! Don't forget that you have to wait one minute before refreshing this page to see your comment!

asdfsadf - 17:40 21/05/2021
asdfasdfasdfasdfsaf

testt - 17:41 21/05/2021
est

55 - 18:30 21/05/2021
55

dakujem - 18:38 21/05/2021
serus

gghh - 19:08 21/05/2021

yyyyyyyy - 19:37 21/05/2021
yyyyyyyy

**** - 19:44 21/05/2021

this is a test - 20:19 21/05/2021
wow wtf

gwdsdg - 20:25 21/05/2021
gggewgg sd mdgkgj sdkjgsodj g12 jr128 jdg sdg sdg jo sdjgojidsgdsg sodj g

gwdsdg - 20:25 21/05/2021
gggewgg sd mdgkgj sdkjgsodj g12 jr128 jdg sdg sdg jo sdjgojidsgdsg sodj g

sdgsdgsdg - 20:25 21/05/2021
Your Message Has Been Sent! Go back to the article after 1 minute and refresh the page to see your comment within the article!

sdg - 20:25 21/05/2021
dsgsdgsdgdgsdg

**** - 20:33 21/05/2021

For the Algo!

If you enjoyed this article, give it a and don't forget:

Leave a comment for the algorithm! (even if it is just to say how silly I am !)


Original Link: https://dev.to/inhuofficial/i-built-a-3-page-interactive-spa-with-a-single-image-element-and-no-css-extreme-ssr-4knk

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To