Web Development

spartanatreyu , in Is it possible to get the value of a CSS property in an HTML element, using XPath 1.0?
@spartanatreyu@programming.dev avatar

Asking just because I'm curious... why are you using xpath?

Also, is this for a website you control or for some else's website?

If you're rendering the page (in a browser, e2e test-runner, spider bot, etc...), have you considered running some js on the page to get the image? Something like: const imagePath = document.getElementById('exampleIdOnElement').style.backgroundImage

Kalcifer OP ,
@Kalcifer@sh.itjust.works avatar

Asking just because I’m curious… why are you using xpath?

I'm using a service called FreshRSS that automatically fetches RSS feeds. It has a feature that allows you to create custom feeds for sites by scraping the HTML with user specified XPath expressions.

I know that this isn't exactly "web development", but it uses webdev tools, and I wasn't entirely sure where else to post this.

If you’re rendering the page (in a browser, e2e test-runner, spider bot, etc…), have you considered running some js on the page to get the image? Something like: const imagePath = document.getElementById('exampleIdOnElement').style.backgroundImage

JS is, unfortunately, not possible here. I can only use XPath expressions.

DuffmanOfTheCosmos , in I made a thing

This is cool, but it bothers me that the inhale cycle doesn't end with completely filling the circle with blue. I feel unfulfilled, like when the DVD player screensaver doesn't hit neatly into the corner of the screen when it totally looks like it's going to

spartanatreyu OP , (edited )
@spartanatreyu@programming.dev avatar

Lol, well I could change it, but it was based on the gif at https://quietkit.com/box-breathing/

I think it's because you're not supposed to expand your lungs so much that they feel like they're going to burst.

But if you scroll to the bottom of the css and look at line 69, you can change transform: scale(90%); to transform: scale(100%); to see if you like it better.

DuffmanOfTheCosmos ,

Haha nice, thanks!

Max_P , in Do we need Live Reload (Watch) in bundlers?
@Max_P@lemmy.max-p.me avatar

Incremental builds are much faster as it often only need to rebuild the specific part that changed. Just re-running the build in VSCode won't help you if the build takes like 5 minutes, but still instant with watch mode.

Hot reload also has some advantages such as not having to reload the page and lose state: it can just update the CSS live so you can quickly iterate on your styles even if you're deep into the navigation at page 10 of a modal window.

We don't need live reload/watch, but it sure is convenient.

trymeout OP ,

Why could a build take 5 minutes? Is it due to the size of your project or the language the bundler is written in (JavaScript being a slower option over Rust)?

Max_P ,
@Max_P@lemmy.max-p.me avatar

The scale of things. Large projects take longer to compile and bundle because they're made out of thousands of files and hundreds of thousands of lines of code.

Yeah, your hello program will go just as fast without a bundler, or a simple bundler. It's when you go big, and use tons of libraries and stuff that it slows down and the advantages become clearer.

That's especially true when using big libraries like React and dozens of plugins for it, frameworks like Next.js, SASS for CSS or CSS in JS, all the JSX, all the TypeScript. It adds up especially if Babel is also involved to transpile for older browser support.

5 minutes is a bit of an extreme use case, but the point is after the first build, live reload would still refresh your code at the same speed. So working on one page you don't need to constantly rebuild the other hundreds of them, just the one you changed. If you target mobile platforms with Cordova or React Native then you also add a whole Android/iOS build + install + restart of the app. The same live reload would work even in that context, making the speed advantage even more apparent.

These things are designed for large enterprise projects, not for your small helloworld sized hobbyist programs.

superb ,
@superb@lemmy.blahaj.zone avatar

Are incremental builds only available when you’re hot reloading?

Max_P ,
@Max_P@lemmy.max-p.me avatar

Depends entirely on the bundler. They all have a watch mode, not all of them do hot reload. Hot reload is cool but full of gotchas, it's a hack but worst case you reload the page anyway. Some probably cache on disk, I think webpack can.

But if you think about it, you either want a clean build for production, or rebuild quickly during development. Watch mode does exactly what you'd do anyway, re-run a build. And IDEs can watch its output to give you error messages.

It's much easier to implement: just emit the code again when the file changes, and let it go through the pipeline. It's already there in memory all figured out, no need to figure a serialization format to put on disk to load back up.

But to circle back to the original question of why use watch mode when you can just rebuild it when saving a file: you're reinventing the wheel, and watch mode scales better and will always be faster. Yes, some people need watch mode.

superb ,
@superb@lemmy.blahaj.zone avatar

I’m not a JS user, I was just surprised that bundlers were so bad

lqdrchrd , in You would think it would be easier for Canadians to get sponsorship

Immigration is very difficult, time consuming and expensive. Hiring someone already in the country is easy, quick and free.

Maddier1993 ,

Which is the #1 phrase repeated whenever I search for how to immigrate to EU/US.

Which i guess is worth bearing in mind and not place lofty expectations on the immigration lottery.

Maddier1993 , in You would think it would be easier for Canadians to get sponsorship

For decades, outsourcing was happening to India and other east asian countries to cut costs. This happened even under low interest rate for loans.

Now that interests are higher the cost cutting and outsourcing only increase.

My own feelings are that we really should figure out if we want to work for such lowballers who cut us off like parasites at the first sign of trouble.

It would be prudent for workers to seek work in smaller, private companies. While they have the risk of going bust... they're hopefully not laying off people in the same breath as announcing record growth.

slazer2au , in 6 Best Embedded Databases for 2024
  1. SQLite
  2. DuckDB
  3. RocksDB
  4. Chroma
  5. Kùzu
  6. Faiss
Dendr0 , (edited ) in Is owning websites for private individuals become forbidden by our governments ?

Most of that only applies if you're running your website as a public-facing entity, i.e. open to the general public to browse/use or if you're running it as part of a business.

If it's a non-commercial, private-use site you don't need any of those "requirements".

-edit- Obviously depending on jurisdiction.

Vincent , in Federated Credential Management (FedCM) API - Web APIs | MDN

To make this work well with the Fediverse, you'd need to be able to specify your own server (e.g. programming.dev), which is under discussion at https://github.com/fedidcg/FedCM/issues/240.

ericjmorey ,
@ericjmorey@programming.dev avatar

To make it work in a way that preserves privacy as a value held by many current users of federated social services, yes.

But it seems like it can be implemented as is in any federated service and improve security for 3rd party frontend apps.

Maybe I'm missing something essential, but holding out for a perfect implementation which may not be broadly adapted might be a mistake on a developer's part if they want to provide value to ther service they're developing for.

Ember_Rising , in XMLHttpRequest (XHR) Vs Fetch API

Also, you can use Wretch for a really neat builder pattern to make requests.

https://elbywan.github.io/wretch/

Max_P , in XMLHttpRequest (XHR) Vs Fetch API
@Max_P@lemmy.max-p.me avatar

XHR is absolutely ancient. Like, I used it on Internet Explorer 6 era websites. Using a 3x3 table with images in all 8 outer cells to make rounded corners.

It still works but is so old it can't really be updated. It's entirely callback driven so no async. It's not even async by default if I recall correctly, it just hangs the browser.

The Fetch API was designed to modernize what XHR does, and does so well. Now, a simple get request you can pretty much await fetch(...) whereas the XHR one is probably 20-40 lines of code and most people end up using a library to deal with it, or write their own little wrapper for it. It supports promises natively.You can stream very large files without loading it all in memory. There's nothing XHR can do that fetch can't do, and usually does it better too. For most use cases the performance will be the same, network IO is orders of magnitude slower than JavaScript execution. But the API being better probably does lead to better performance by not doing unnecessary things and possibly processing data as it arrives instead of all in one go when the download is finished.

It's a modern replacement because it's literally what it was designed to be. Try both and it'll be abundantly clear why.

Corsair OP ,
@Corsair@programming.dev avatar

Thanks @Max_P weird because I can use XHR as async..
see: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open
open(method, url, async)

SteveTech ,

Sure it let's you use it asynchronously, but it predates and is not really compatible with JavaScript's async/Promise API.

walter_wiggles , in XMLHttpRequest (XHR) Vs Fetch API

I think of XHR as more of a low-level API. Most of the time though you don't need access to those low-level details.

The fetch API is bit higher level and nicer to work with.

NostraDavid , in Back to Basics in Web Apps

I find it refreshing to write, not generate, HTML and CSS, and then sprinkle some JavaScript for interactivity.

I've found hugo to be rather amazing in generating static HTML and CSS (converting either HTML or Markdown templates into regular HTML).

I started out my personal website as:

PS: Have you ever seen TheNet (1995)?

PPS: All the HTML is pretty much all Semantic HTML, instead of Twitter's div>div>div>div>div

Aijan OP ,

Author here. My blog is also generated with Hugo, and it's great. I just prefer not to generate HTML and CSS from JavaScript unless it's necessary.

Sorry, I haven’t seen that movie. Thanks for the recommendation though.

NostraDavid ,

Too bad you haven't seen it - my site has a little easter egg from that movie :3

victorz ,

div>div>div>div>div

Ah yes, div soup.

By the way, have you tried different generators and compared them, or tried only Hugo, out of curiosity?

NostraDavid ,

Only Hugo; I didn't want to try anything JS based and hugo is faaaaaast in its generation. Sub 1 second fast. It's so nice.

victorz ,

Cool! Very nice. Do you need it to be that fast or is it just nice because faster is better?

elbarto777 , in It's a smolsite! This whole site fits inside the URL!

Neat project! I wonder what the max url length is. It's implementation-dependant, right?

Lmaydev ,

From a quick Google yes. Numbers below are likely out of date though.

Chrome
2,083 characters

Firefox
65,536 characters

Safari
80,000 characters

Internet Explorer
2,083 characters

elbarto777 ,

64K in a URL on Firefox? Wow! That was the RAM size of home computers in the early 80s. Wild.

mozz Admin , in Anyone able to help with my website being slow to certain sections?
mozz avatar

Can you show a screenshot of the waterfall display while loading with a fresh cache / without the fresh cache?

mac OP ,
@mac@infosec.pub avatar

I looked at the waterfall and I realised I had some design images in there at 2500+ resolution that were taking 5s to load and that was interfering with the loading of the JS.

Thanks, I'll make sure to check this tab first before posting next time.

mozz Admin ,
mozz avatar

All good 👍🏻

onlinepersona , (edited ) in Understand the Next Phase of Web Development - Steve Sanderson - NDC London 2024

From Microsoft? Oh no... is this a blazor sales pitch?

Edit: not really. Of course he had to use it, but it wasn't too prominent. Didn't finish the video but server-side rendering seems to be the "future". I dunno... that doesn't give me a warm tingly feeling.

Anti Commercial-AI license

LPThinker OP ,

More specifically, he argued (and the recent and upcoming releases of most major frameworks agree) that rendering most content on the server with islands of client-side interactivity is the future.

That’s not necessarily a huge revelation, but the big difference from what people have been doing with PHP for decades is the level of integration and simplicity in mixing server-side and client-side code seamlessly so that a dev can choose the appropriate thing in each context and not have to go through a lot of effort when requirements change or scaling becomes an issue. I would say that this represents a new level of maturity in the “modern” web frameworks where devs can choose the right technology for every problem to serve their users best.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • webdev@programming.dev
  • test
  • worldmews
  • mews
  • All magazines